-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
98 lines (86 loc) · 2.24 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
const gulp = require('gulp');
const gzip = require('gulp-gzip');
const connect = require('gulp-connect');
const gulpSequence = require('gulp-sequence');
const closure = require('dj-gulp-tasks/closure');
// Configs
const depsConfig = {
'output': './etc/momentum.deps.js',
'prefix': '../../../../',
'files': [
'./src/**/*.js'
]
};
const mainBuildConfig = {
'output': './dist/momentum.min.js',
'files': [
'./node_modules/google-closure-library/closure/goog/base.js',
'./src/momentum/**/*.js'
],
'config': {
'closure_entry_point': 'momentum',
'externs': [
'./etc/momentum.externs.js'
],
}
};
const moduleBuildConfig = {
'output': './dist/index.js',
'files': [
'./node_modules/google-closure-library/closure/goog/base.js',
'./src/momentum/**/*.js'
],
'config': {
'closure_entry_point': 'momentum.module',
'externs': [
'./etc/momentum.externs.js'
]
}
};
const debugBuildConfig = {
'output': './dist/debug/momentum.min.js',
'files': [
'./node_modules/google-closure-library/closure/goog/base.js',
'./src/**/*.js'
],
'config': {
'closure_entry_point': 'momentumdebug',
'externs': [
'./etc/momentum.externs.js'
]
}
};
gulp.task('js-dist-main-build', () => closure.distCompile(mainBuildConfig));
gulp.task('js-dist-module-build', () => closure.distCompile(moduleBuildConfig));
gulp.task('js-dist-debug-build', () => closure.distCompile(debugBuildConfig));
gulp.task('js-deps-build', () => closure.depsBuild(depsConfig));
gulp.task('js-deps-watch', ['js-deps-build'], () => {
return closure.depsWatch(depsConfig, () => gulp.start('js-deps-build'))
});
// Tasks
gulp.task('compress-js', () => {
gulp.src('./dist/momentum.min.js')
.pipe(gzip())
.pipe(gulp.dest('./dist/'));
gulp.src('./dist/debug/momentum.min.js')
.pipe(gzip())
.pipe(gulp.dest('./dist/debug/'));
});
gulp.task('build', gulpSequence(
'js-dist-main-build',
'js-dist-module-build',
'js-dist-debug-build',
'compress-js'
));
gulp.task('server', () => {
return connect.server({
host: '0.0.0.0',
root: ['./demos', './'],
livereload: true,
port: 8000
});
});
gulp.task('start', () => {
gulp.start('js-deps-watch', 'server');
});
gulp.task('default', ['build']);