-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
63 lines (52 loc) · 1.35 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
const gulp = require('gulp');
require('./build/compile');
require('./build/preview');
const nodemonOptions = {
script: './preview/server.js',
ext: 'js jsx',
watch: [
'lib/*',
'preview/*',
],
ignore: [
'build',
'src/',
'preview/public/',
'test/',
'node_modules',
],
delay: 1500,
};
const scripts = [
'src/**/*.jsx',
'preview/**/*.jsx',
'preview/**/*.js',
'!preview/public/*.js',
'!preview/server.js',
];
const stylesheets = [
'src/**/*.scss',
'preview/**/*.scss',
];
gulp.task('build', gulp.series(
'compile:clean',
'preview:clean',
gulp.parallel('compile:babel', 'compile:styles'),
gulp.parallel('preview:babel', 'preview:styles'),
));
gulp.task('watch', (done) => {
const livereload = require('tiny-lr');
const nodemon = require('nodemon')(nodemonOptions);
const reloadPage = () => { livereload.changed('script.js'); };
const reloadStylesheets = () => {
livereload.changed('style.css');
return Promise.resolve();
};
livereload().listen();
nodemon.on('log', (log) => { console.log(log.colour); });
nodemon.on('start', () => setTimeout(reloadPage, 1500));
gulp.watch(scripts, gulp.series('compile:babel', 'preview:babel'));
gulp.watch(stylesheets, gulp.series('compile:styles', 'preview:styles', reloadStylesheets));
done();
});
gulp.task('default', gulp.series('build', 'watch'));