-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
66 lines (58 loc) · 1.28 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
64
65
66
const gulp = require('gulp'),
browserSync = require('browser-sync')
const paths = {
output: './docs',
src: {
html: './src/html',
css: './src/css',
js: './src/js'
}
}
function html(){
return gulp.src(`${paths.src.html}/*.html`)
.pipe(gulp.dest(paths.output));
}
function css(){
return gulp.src(`${paths.src.css}/*.css`)
.pipe(gulp.dest(paths.output));
}
function js(){
return gulp.src(`${paths.src.js}/*.js`)
.pipe(gulp.dest(paths.output));
}
function serve(){
browserSync({
injectChanges: true,
notify: false,
server: paths.output,
tunnel: false
});
watch();
}
function watch(){
const watchers = [
{
glob: `${paths.src.html}/*.html`,
tasks: [html]
},
{
glob: `${paths.src.css}/*.css`,
tasks: [css]
},
{
glob: `${paths.src.js}/*.js`,
tasks: [js]
}
];
watchers.forEach(watcher => {
gulp.watch(watcher.glob)
.on('change', gulp.series(html, css, js, browserSync.reload))
});
}
/// Gulp
gulp.task('html', html);
gulp.task('css', css);
gulp.task('js', js);
gulp.task('serve', gulp.series('html', 'css', 'js', serve, (done) => {
done();
}));