forked from udacity/mws-restaurant-stage-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
46 lines (41 loc) · 1.04 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
/* eslint-env node */
const gulp = require('gulp');
const config = require('./gulpfile.config.js');
const imports = require('./gulpfile.imports.js');
const {browserSync} = imports;
const taskFiles = [
'./tasks/util.js',
'./tasks/html.js',
'./tasks/sass.js',
'./tasks/js.js',
'./tasks/images.js',
'./tasks/misc.js'
];
taskFiles.forEach(taskFile => {
require(taskFile)({gulp, config, imports});
});
gulp.task('build', gulp.series(
'clean',
'mkdir',
gulp.parallel(
'html',
'sass',
'js',
'images',
'misc'
)
));
gulp.task('serve', gulp.series('build', () => {
browserSync.init({
proxy: config.server.url
});
gulp.watch(config.patterns.sass, gulp.series('sass'));
gulp.watch(config.patterns.html, gulp.series('html')).
on('change', browserSync.reload);
gulp.watch([config.patterns.js, config.patterns.sw], gulp.series('js')).
on('change', browserSync.reload);
}));
let defaultTask = 'serve';
if (process.env.NODE_ENV === 'production')
defaultTask = 'build';
gulp.task('default', gulp.series(defaultTask));