-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
52 lines (48 loc) · 1.22 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
const gulp = require('gulp');
const browserSync = require('browser-sync');
const reload = browserSync.reload;
const parcel = require('gulp-parcel');
gulp.task('server', ()=>{
browserSync.init({
server: {
baseDir: './dist'
},
port: 2333,
open: false
})
gulp.watch(['./src/js/**/*.js', './src/**/*.html', './src/images/*.{png,jpg,jpeg,gif,svg}']).on('change', (e)=>{
setTimeout(() => {
reload()
}, 100);
});
gulp.watch(['./dist/*.css']).on('change', (e)=>{
reload(e.path)
});
})
gulp.task('start', ()=>{
gulp.src('./src/**/*.html', {read:false})
.pipe(parcel({
outDir: './dist',
publicURL: './',
minify: false,
watch: true,
sourceMaps: true,
cache: true,
cacheDir: '.parcelCache',
}))
.pipe(gulp.dest('./dist'))
})
gulp.task('build', ()=>{
gulp.src('./src/**/*.html', {read:false})
.pipe(parcel({
outDir: './dist',
publicURL: './',
minify: true,
watch: false,
sourceMaps: false,
cache: false,
cacheDir: '.parcelCache',
}))
.pipe(gulp.dest('./dist'))
})
gulp.task('default', ['start', 'server']);