forked from hoch/WAAX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
110 lines (89 loc) · 2.92 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
/**
* WAAX project gulp task file (1.0.0-alpha3)
*
* gulp # build everything and serve at 127.0.0.1:3000
* gulp clean # cleans dist, build path
* gulp core # minifies and concats core JS files to build/
* gulp plugins # minifies plug-in JS files to build/plug_ins
* gulp mui # copies MUI elements files to build/
* gulp serve # starts dev server 127.0.0.1:3000 and opens Chrome
* gulp build # build and minify core, plug-ins
*/
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')(),
browserSync = require('browser-sync'),
runSequence = require('run-sequence'),
del = require('del');
var wrap = require('gulp-wrap');
var reload = browserSync.reload;
var WX_CORE = [
'src/waax.js',
'src/waax.extension.js',
'src/waax.util.js',
'src/waax.core.js',
'src/waax.timebase.js',
'src/mui/mui.js'
];
var WX_PLUGINS = [
'src/plug_ins/**/*.js'
];
// Clean: Empty the build directory before a complete build.
gulp.task('clean', del.bind(null, [
'build/**/*',
'!build'
]));
// Everything: Build core and plug-ins.
gulp.task('core', function () {
return gulp.src(WX_CORE)
.pipe(plugins.uglify({ mangle: false }))
.pipe(plugins.concat('waaxcore.min.js'))
.pipe(wrap('(function () {\n"use strict";\n<%= contents %>\n})();'))
.pipe(gulp.dest('build'))
.pipe(plugins.size({ title: 'core' }));
});
gulp.task('plugins', function () {
return gulp.src(WX_PLUGINS)
.pipe(plugins.uglify({ mangle: false }))
.pipe(plugins.concat('plugins.min.js'))
.pipe(gulp.dest('build'))
.pipe(plugins.size({ title: 'plugins' }));
});
gulp.task('everything', ['core', 'plugins'], function () {
gulp.src(['build/waaxcore.min.js', 'build/plugins.min.js'])
.pipe(plugins.concat('waax.min.js'))
.pipe(gulp.dest('build'))
.pipe(plugins.size({ title: 'everything' }));
});
// MUI: Build MUI elements into build/mui/ path.
gulp.task('mui', function () {
return gulp.src([
'src/mui/**/*',
'!src/mui/bower.json'
])
.pipe(gulp.dest('build/mui'))
.pipe(plugins.size({ title: 'mui' }));
});
// Serve: Start a dev server at 127.0.0.1:3000.
gulp.task('serve', function () {
browserSync({
notify: false,
server: {
baseDir: './'
},
browser: 'google chrome'
// browser: 'google chrome canary'
});
gulp.watch(['src/*.js', '!src/ktrl.js'], ['everything', reload]);
gulp.watch(['src/plug_ins/**/*.js'], ['everything', reload]);
gulp.watch(['src/mui/**/*.html'], ['mui', reload]);
gulp.watch(['examples/**/*'], reload);
gulp.watch(['test/**/*.html', 'test/**/*.js'], reload);
});
// Build: Clean and build everything in build/ path.
gulp.task('build', function (cb) {
runSequence('clean', ['everything', 'mui'], cb);
});
// Default: Build and serve.
gulp.task('default', function (cb) {
runSequence('build', 'serve', cb);
});