-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathgulpfile.babel.js
executable file
·51 lines (43 loc) · 1.16 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
import gulp from 'gulp';
import path from 'path';
import webpack from 'webpack-stream';
const browserSync = require('browser-sync');
const reload = () => browserSync.reload();
const root = 'client';
// helper method for resolving paths
const resolveToApp = (glob) => {
glob = glob || '';
return path.join(root, 'app', glob); // app/{glob}
};
// map of all paths
const 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
};
gulp.task('webpack', () => {
return gulp.src(paths.entry)
.pipe(webpack(require('./webpack.config')))
.pipe(gulp.dest(paths.output));
});
gulp.task('reload', ['webpack'], (done) => {
reload();
done();
});
gulp.task('serve', ['webpack'], () => {
browserSync({
port: process.env.PORT || 3000,
open: false,
server: { baseDir: root }
});
});
gulp.task('watch', ['serve'], () => {
const allPaths = [].concat([paths.js], paths.html, [paths.styl]);
gulp.watch(allPaths, ['reload']);
});
gulp.task('default', ['watch']);