-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
77 lines (60 loc) · 1.94 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
var path = require('path'),
ymb = require('ymb'),
plg = ymb.plugins,
gulp = ymb.gulp,
gulpBabel = require('gulp-babel');
var cfg = ymb.resolveBuildConfig();
gulp.task('ym-clean', function (cb) {
ymb.del(path.resolve(cfg.dest), { force: true }, cb);
});
gulp.task('ym-rebuild', function () {
var async = cfg.store == 'async',
standalone = cfg.target == 'standalone',
chain = [],
js, css, templates, modules;
js = gulp.src(cfg.src.js);
css = gulp.src(cfg.src.css)
.pipe(plg.css.optimize(cfg))
.pipe(plg.css.toModules(cfg));
templates = gulp.src(cfg.src.templates)
.pipe(plg.templates.compile(cfg))
.pipe(plg.templates.toModules(cfg));
modules = ymb.es.merge(js, css, templates);
if (cfg.babel) {
chain.push(gulpBabel());
}
chain.push(plg.modules.setup(cfg));
chain.push(plg.modules.ym(cfg));
if (standalone) {
chain.push(plg.modules.plus(cfg));
chain.push(plg.modules.helpers(cfg));
if (async) {
chain.push(plg.modules.map(cfg));
chain.push(plg.modules.async(cfg));
}
chain.push(plg.modules.namespace(cfg));
} else {
if (async) {
chain.push(plg.modules.map(cfg));
chain.push(plg.modules.async(cfg));
}
}
chain.push(plg.modules.init(cfg));
chain.push(plg.modules.store(cfg));
if (cfg.minify) {
chain.push(plg.modules.minify(cfg));
}
return modules
.pipe(plg.util.pipeChain(chain))
.pipe(gulp.dest(path.resolve(cfg.dest)));
});
gulp.task('ym-build', ['ym-clean', 'ym-rebuild']);
gulp.task('ym-watch', ['ym-build'], function () {
var watcher = gulp.watch([cfg.src.js, cfg.src.css, cfg.src.templates], ['ym-rebuild']);
watcher.on('change', function (e) {
if (e.type == 'deleted') {
plg.remember.forget('ymb#default', e.path);
}
});
return watcher;
});