forked from alxmtr/gulp-pug-sass-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
51 lines (41 loc) · 1.09 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
const { src, dest, watch, series } = require('gulp')
const pug = require('gulp-pug')
const sass = require('gulp-sass')
const browserSync = require('browser-sync').create()
// Compile pug files into HTML
function html() {
return src('src/pug/*.pug')
.pipe(pug())
.pipe(dest('dist'))
}
// Compile sass files into CSS
function styles() {
return src('src/sass/main.sass')
.pipe(sass({
includePaths: ['src/sass'],
errLogToConsole: true,
outputStyle: 'compressed',
onError: browserSync.notify
}))
.pipe(dest('dist/css'))
.pipe(browserSync.stream())
}
// Copy assets
function assets() {
return src('src/assets/**/*')
.pipe(dest('dist/'))
}
// Serve and watch sass/pug files for changes
function watchAndServe() {
browserSync.init({
server: 'dist',
})
watch('src/sass/**/*.sass', styles)
watch('src/pug/*.pug', html)
watch('src/assets/**/*', assets)
watch('dist/*.html').on('change', browserSync.reload)
}
exports.html = html
exports.styles = styles
exports.watch = watchAndServe
exports.default = series(html, styles, assets, watchAndServe)