forked from ansible/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
143 lines (127 loc) · 4.36 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
const gulp = require('gulp');
const less = require('gulp-less');
const dest = require('gulp-dest');
const watch = require('gulp-watch');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const gutil = require('gulp-util');
const proxy = require('http-proxy-middleware')
const sync = require('browser-sync')
const history = require('connect-history-api-fallback')
gulp.task('server', function() {
const proxyDjango = proxy('/', {target: 'http://localhost:8888', xfwd: true})
sync.init({
notify: false,
open: false,
port: 8000,
server: {
baseDir: '/galaxy',
middleware: [proxyDjango, history()]
}
});
});
gulp.task('accountApp', function() {
return gulp.src([
'./galaxy/static/js/accountApp/*.js',
'./galaxy/static/js/commonDirectives/*.js',
'./galaxy/static/js/commonServices/*.js'
])
.pipe(concat('galaxy.accountApp.js'))
.pipe(uglify({ 'mangle': true, 'compress': true }))
.pipe(rename({extname: ".min.js"}))
.pipe(gulp.dest('./galaxy/static/dist'));
});
gulp.task('detailApp', function() {
return gulp.src([
'./galaxy/static/js/detailApp/*.js',
'./galaxy/static/js/commonDirectives/*.js',
'./galaxy/static/js/commonServices/*.js'
])
.pipe(concat('galaxy.detailApp.js'))
.pipe(uglify({ 'mangle': true, 'compress': true }))
.pipe(rename({extname: ".min.js"}))
.pipe(gulp.dest('./galaxy/static/dist'));
});
gulp.task('listApp', function() {
return gulp.src([
'./galaxy/static/js/listApp/*.js',
'./galaxy/static/js/commonDirectives/*.js',
'./galaxy/static/js/commonServices/*.js'
])
.pipe(concat('galaxy.listApp.js'))
.pipe(uglify({ 'mangle': true, 'compress': true }))
.pipe(rename({extname: ".min.js"}))
.pipe(gulp.dest('./galaxy/static/dist'));
});
gulp.task('exploreApp', function() {
return gulp.src([
'./galaxy/static/js/exploreApp/*.js',
'./galaxy/static/js/commonDirectives/*.js',
'./galaxy/static/js/commonServices/*.js'
])
.pipe(concat('galaxy.exploreApp.js'))
.pipe(uglify({ 'mangle': true, 'compress': true }))
.pipe(rename({extname: ".min.js"}))
.pipe(gulp.dest('./galaxy/static/dist'));
});
gulp.task('importStatusApp', function() {
return gulp.src([
'./galaxy/static/js/importStatusApp/*.js',
'./galaxy/static/js/commonDirectives/*.js',
'./galaxy/static/js/commonServices/*.js'
])
.pipe(concat('galaxy.importStatusApp.js'))
.pipe(uglify({ 'mangle': true, 'compress': true }))
.pipe(rename({extname: ".min.js"}))
.pipe(gulp.dest('./galaxy/static/dist'));
});
gulp.task('roleAddApp', function() {
return gulp.src([
'./galaxy/static/js/roleAddApp/*.js',
'./galaxy/static/js/commonDirectives/*.js',
'./galaxy/static/js/commonServices/*.js'
])
.pipe(concat('galaxy.roleAddApp.js'))
.pipe(uglify({ 'mangle': true, 'compress': true }))
.pipe(rename({extname: ".min.js"}))
.pipe(gulp.dest('./galaxy/static/dist'));
});
gulp.task('userStarredApp', function() {
return gulp.src([
'./galaxy/static/js/userStarredApp/*.js',
'./galaxy/static/js/commonDirectives/*.js',
'./galaxy/static/js/commonServices/*.js'
])
.pipe(concat('galaxy.userStarredApp.js'))
.pipe(uglify({ 'mangle': true, 'compress': true }))
.pipe(rename({extname: ".min.js"}))
.pipe(gulp.dest('./galaxy/static/dist'));
});
gulp.task('less', function() {
return gulp.src(['./galaxy/static/less/galaxy.less'])
.pipe(less({
compress: true
}))
.on('error', gutil.log)
.pipe(dest('galaxy/static/css', {ext: '.min.css'}))
.pipe(gulp.dest('./'));
});
gulp.task('less-watch', ['less'], function (done) {
sync.reload();
done();
});
gulp.task('generic-watch', function(done) {
sync.reload();
done();
});
gulp.task('watch', function () {
gulp.watch('./galaxy/static/less/*.less', ['less-watch']);
gulp.watch('./galaxy/static/js/*/*.js', ['generic-watch']);
gulp.watch('./galaxy/static/partials/*.html', ['generic-watch']);
});
gulp.task('default', ['less', 'server', 'watch']);
gulp.task('build', [
'less', 'accountApp', 'listApp', 'detailApp',
'exploreApp', 'roleAddApp', 'importStatusApp', 'userStarredApp'
]);