-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
63 lines (55 loc) · 1.59 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
57
58
59
60
61
62
63
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
browserSync = require('browser-sync');
cssnano = require('gulp-cssnano')
terser = require('gulp-terser');
rename = require('gulp-rename');
var plumberErrorHandler = {
errorHandler: notify.onError({
title: 'Gulp',
message: 'Error: <%= error.message %>'
})
};
gulp.task('sass', function() {
return gulp
.src('./sass/*.scss')
.pipe(plumber(plumberErrorHandler))
.pipe(sass())
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(cssnano())
.pipe(rename({extname: '.min.css'}))
.pipe(gulp.dest('./build/css'))
});
gulp.task('scripts', function(){
return gulp
.src('./js/*.js')
.pipe(terser())
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest('./build/js'))
});
gulp.task('scripts2', function(){
return gulp
.src('./js/vendor/*.js')
.pipe(terser())
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest('./build/js'))
});
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch(['build/css/*.css', 'build/js/*.js']).on('change', browserSync.reload);
});
gulp.task('watch', function() {
gulp.watch('sass/*.scss', gulp.series('sass'));
gulp.watch('js/*.js', gulp.series('scripts'));
gulp.watch('js/vendor/*.js', gulp.series('scripts2'));
});
gulp.task('default', gulp.parallel('watch', 'browser-sync'));