-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgulpfile.js
56 lines (46 loc) · 1.25 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
const preprocess = require('gulp-preprocess')
const postcss = require('gulp-postcss')
var pug = require('gulp-pug');
var del = require('del');
const { watch, dest, src, series, parallel } = require('gulp')
const html = function() {
return src('./src/*.pug')
.pipe(preprocess({ context: { curtime: Date.now() } }))
.pipe(pug())
.pipe(dest('./dist/'))
}
const scripts = function() {
return src(['./src/**/*.js'])
.pipe(preprocess())
.pipe(dest('./dist/'))
}
const css = function() {
return src('./src/**/*.css')
.pipe(postcss())
.pipe(preprocess())
.pipe(dest('./dist/'))
}
const static = function() {
return src('./static/**/*.*')
.pipe(dest('./dist/'))
}
function serve() {
const browserSync = require('browser-sync').create()
watch('./src/**/*.js', scripts)
watch('./src/**/*.css', css)
watch('./src/**/*.pug', html)
watch('./static/**/*.*', static)
browserSync.init({
server: {
baseDir: "dist",
serveStaticOptions: {
extensions: ["html"]
}
},
ui: false,
})
watch('dist/**/*.*').on('change', browserSync.reload)
}
exports.dev = series(scripts, css, html, static, serve)
exports.clean = () => del(['dist/*'], { dot: true });
exports.build = parallel(scripts, css, html, static)