forked from simpulton/eggly-es6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
executable file
·52 lines (44 loc) · 1.19 KB
/
gulpfile.babel.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
'use strict';
import gulp from 'gulp';
import webpack from 'webpack-stream';
import path from 'path';
import sync from 'run-sequence';
import serve from 'browser-sync';
let reload = () => serve.reload();
let root = 'client';
// helper method for resolving paths
let resolveToApp = (glob) => {
glob = glob || '';
return path.join(root, 'app', glob); // app/{glob}
};
// map of all paths
let paths = {
js: resolveToApp('**/*!(.spec.js).js'), // exclude spec files
styl: resolveToApp('**/*.styl'), // stylesheets
html: [
resolveToApp('**/*.html'),
path.join(root, 'index.html')
],
entry: path.join(root, 'app/app.js'),
output: root
};
// use webpack.config.js to build modules
gulp.task('webpack', () => {
return gulp.src(paths.entry)
.pipe(webpack(require('./webpack.config')))
.pipe(gulp.dest(paths.output));
});
gulp.task('serve', () => {
serve({
port: process.env.PORT || 3000,
open: false,
server: { baseDir: root }
});
});
gulp.task('watch', () => {
let allPaths = [].concat([paths.js], paths.html, [paths.styl]);
gulp.watch(allPaths, ['webpack', reload]);
});
gulp.task('default', (done) => {
sync('webpack', 'serve', 'watch', done);
});