-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
52 lines (46 loc) · 1.23 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
const { src, dest, watch, series } = require("gulp");
const sass = require("gulp-sass")(require("sass"));
const postcss = require("gulp-postcss");
const autoprefixer = require("autoprefixer");
const cssnano = require("cssnano");
const babel = require("gulp-babel");
const terser = require("gulp-terser");
const browsersync = require("browser-sync").create();
function scssTask() {
return src("app/scss/style.scss", { sourcemaps: true })
.pipe(sass())
.pipe(postcss([autoprefixer(), cssnano()]))
.pipe(dest("dist", { sourcemaps: "." }));
}
function jsTask() {
return src("app/js/script.js", { sourcemaps: true })
.pipe(babel({ presets: ["@babel/preset-env"] }))
.pipe(terser())
.pipe(dest("dist", { sourcemaps: "." }));
}
function browserSyncServe(cb) {
browsersync.init({
server: {
baseDir: ".",
},
notify: {
styles: {
top: "auto",
bottom: "0",
},
},
});
cb();
}
function browserSyncReload(cb) {
browsersync.reload();
cb();
}
function watchTask() {
watch("*.html", browserSyncReload);
watch(
["app/scss/**/*.scss", "app/**/*.js"],
series(scssTask, jsTask, browserSyncReload)
);
}
exports.default = series(scssTask, jsTask, browserSyncServe, watchTask);