-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
66 lines (59 loc) · 1.65 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
64
65
66
const { src, dest, series, watch } = require("gulp");
const sass = require("gulp-sass")(require("sass"));
const csso = require("gulp-csso");
const include = require("gulp-file-include");
const htmlmin = require("gulp-htmlmin");
const concat = require("gulp-concat");
const autoprefixer = require("gulp-autoprefixer");
const sync = require("browser-sync").create();
const gulp = require("gulp");
const imagemin = require("gulp-imagemin");
const removeCssComments = require("gulp-remove-css-comments");
function html() {
return src("src/**.html")
.pipe(
include({
prefix: "@@",
})
)
.pipe(
htmlmin({
collapseWhitespace: true,
removeComments: true,
})
)
.pipe(gulp.dest("dist"));
}
function scss() {
return src("src/styles/index.scss")
.pipe(sass())
.pipe(
autoprefixer({
browsers: ["last 2 versions"],
})
)
.pipe(csso())
.pipe(concat("index.css"))
.pipe(removeCssComments())
.pipe(dest("dist"));
}
const js = () => {
return src("src/js/*").pipe(dest("dist/"));
};
function imgs() {
return src("src/img/*").pipe(imagemin()).pipe(dest("dist/img"));
}
function serverFunc() {
sync.init({
server: "./dist",
});
watch("src/**.html", series(html, imgs)).on("change", sync.reload);
watch("src/js/*", series(js)).on("change", sync.reload);
watch("src/parts/**.html", series(html, imgs)).on("change", sync.reload);
watch("src/styles/**.scss", series(scss)).on("change", sync.reload);
}
exports.html = html;
exports.scss = scss;
exports.js = js;
exports.start = series(html, scss, imgs, serverFunc, js);
exports.build = series(html, scss, imgs, js);