-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
59 lines (47 loc) · 1.36 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
var gulp = require('gulp'),
terser = require('gulp-terser'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
autoprefixer = require("gulp-autoprefixer"),
cssnano = require("gulp-cssnano"),
eslint = require('gulp-eslint');
var browserSync = require('browser-sync').create();
gulp.task('scripts', function(){
return gulp.src('./js/*.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(terser())
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('./build/js'))
});
gulp.task('sass', function(){
return gulp
.src("./sass/style.scss")
.pipe(sass())
.pipe(
autoprefixer({
browsers: ["last 2 versions"]
})
)
.pipe(cssnano())
.pipe(rename("style.min.css"))
.pipe(gulp.dest("./build/css"));
})
gulp.task('reload', function(done) {
browserSync.reload();
done();
});
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "./"
}
});
});
gulp.task("watch", function() {
gulp.watch("./js/*.js", gulp.series("scripts", "reload" ));
gulp.watch("./sass/*.scss", gulp.series("sass", "reload" ));
gulp.watch("index.html", gulp.series("reload"));
});
gulp.task('default', gulp.parallel('browser-sync', 'watch', 'scripts', 'sass'))