-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
53 lines (42 loc) · 1.15 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
const gulp = require('gulp')
const pluginOptions = {
DEBUG: true,
camelize: true,
lazy: true
}
const plugins = require('gulp-load-plugins')(pluginOptions)
const onError = err => console.log(`Error = ${err}`);
gulp.task('js', () => {
return gulp.src('./src/js/**/*.js')
.pipe(plugins.plumber({
errorHandler: onError
}))
.pipe(plugins.sourcemaps.init())
.pipe(plugins.concat('index.js'))
.pipe(plugins.babel({
presets: ['@babel/preset-env']
}))
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest('public/js', {
overwrite: true
}))
})
gulp.task('sass', () => {
return gulp.src('./src/scss/style.scss')
.pipe(plugins.plumber({
errorHandler: onError
}))
.pipe(plugins.sourcemaps.init())
.pipe(plugins.sass({
outputStyle: 'compressed'
}))
.pipe(plugins.autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest('public/css', {
overwrite: true
}))
})
gulp.watch(['src/scss/**/*.scss', 'src/js/**/*.js'], gulp.series('sass', 'js'))
gulp.task('default', gulp.series('sass','js'))