-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
67 lines (59 loc) · 1.35 KB
/
gulpfile.babel.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
67
'use strict'
import gulp from 'gulp'
import watch from 'gulp-watch'
import browserSync from 'browser-sync'
import sass from 'gulp-sass'
import autoprefixer from 'gulp-autoprefixer'
import plumber from 'gulp-plumber'
const log = console['log']
const baseConfig = {
sourceDir: './src/',
publishDir: './dist/'
}
const config = {
tasks: {
browserSync: {
port: 8080,
notify: false,
server: {
baseDir: baseConfig.publishDir
},
files: [
`${baseConfig.publishDir}*.html`,
`${baseConfig.publishDir}**/*.html`,
`${baseConfig.publishDir}*.css`
]
},
css: {
src: [
`${baseConfig.sourceDir}scss/!(_)*.scss`,
`${baseConfig.sourceDir}scss/**/!(_)*.scss`
],
watch: [
`${baseConfig.sourceDir}scss/**/*.scss`
]
}
}
}
gulp.task('browser-sync', () => {
browserSync.init(config.tasks.browserSync)
})
gulp.task('scss', () => {
gulp.src(config.tasks.css.src)
.pipe(plumber({
handleError: function (err) {
log(err)
this.emit('end')
}
}))
.pipe(sass())
.pipe(autoprefixer())
.pipe(gulp.dest('./dist/'))
})
gulp.task('scss:watch', () => {
return watch(config.tasks.css.watch, () => {
return gulp.start(['scss'])
})
})
gulp.task('watch', ['scss:watch'])
gulp.task('default', ['browser-sync', 'watch'])