-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
47 lines (42 loc) · 1.11 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
const gulp = require("gulp");
const { series } = require("gulp");
const sass = require('gulp-sass')(require('sass'));
const cleancss = require('gulp-clean-css');
const csscomb = require('gulp-csscomb');
const rename = require('gulp-rename');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require("browser-sync").create();
function build() {
return gulp
.src('./src/*.scss')
.pipe(sass({outputStyle: 'compressed', precision: 10})
.on('error', sass.logError)
)
.pipe(autoprefixer())
.pipe(csscomb())
.pipe(gulp.dest('./dist'))
.pipe(cleancss())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./dist'))
.pipe(browserSync.stream());
}
function watch() {
gulp.watch('./**/*.scss', build);
}
function serve() {
browserSync.init({
server: {
baseDir: "./",
//directory: true,
index: "./dev/index.html"
}
});
gulp.watch("./**/*.scss", build);
gulp.watch("./dev/*.html").on('change', browserSync.reload);
}
exports.watch = watch;
exports.build = build;
exports.default = build;
exports.serve = series(build, serve);