-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
58 lines (35 loc) · 1.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
var del = require('del'),
fs = require('fs'),
gulp = require('gulp'),
babel = require('gulp-babel'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
babel_cfg = require('./config/babel.json'),
browserify_cfg = require('./config/browserify.json');
var production = true,
errorHandler = function(err) {
console.log(err.toString());
this.emit("end");
};
gulp.task('clean', function(cb) {
return del(['./build'], cb);
});
gulp.task('make-dirs', ['clean'], function(cb) {
['./build', './build/js'].map(dir => fs.mkdirSync(dir));
return cb();
});
gulp.task('babel', ['make-dirs'], function() {
return gulp.src('./src/*.js')
.pipe( babel(babel_cfg) )
.pipe( gulp.dest('./build/js') );
});
gulp.task('browserify', ['babel'], function() {
return browserify(browserify_cfg, { "debug" : !production })
.add("./node_modules/mousetrap/mousetrap.js", { "expose" : "mousetrap" })
.require("./build/js/app.js", { "expose" : "app" })
.bundle()
.on("error", errorHandler)
.pipe(source("bundle.js"))
.pipe(gulp.dest('./build/js'));
});
gulp.task('default', ['browserify']);