This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
91 lines (80 loc) · 1.75 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const gulp = require("gulp");
const sass = require("gulp-sass");
const terser = require("gulp-terser");
const cleanCSS = require("gulp-clean-css");
const htmlmin = require("gulp-htmlmin");
const del = require("del");
const imagemin = require("gulp-imagemin");
const paths = {
styles: {
src: "src/styles/**/*.scss",
dest: "dist/styles/"
},
scripts: {
src: "src/js/**/*.js",
dest: "dist/js/"
},
images: {
src: "src/img/**.*",
dest: "dist/img/"
},
ico: {
src: "src/**.ico",
dest: "dist/"
},
html: {
src: "src/**.html",
dest: "dist/"
}
};
function clean() {
return del(["dist"]);
}
function ico() {
return gulp.src(paths.ico.src).pipe(gulp.dest(paths.ico.dest));
}
function html() {
return gulp
.src(paths.html.src)
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest(paths.html.dest));
}
function styles() {
return gulp
.src(paths.styles.src)
.pipe(sass())
.pipe(cleanCSS())
.pipe(gulp.dest(paths.styles.dest));
}
function images() {
return gulp
.src(paths.images.src)
.pipe(imagemin())
.pipe(gulp.dest(paths.images.dest));
}
function scripts() {
return gulp
.src(paths.scripts.src)
.pipe(terser())
.pipe(gulp.dest(paths.scripts.dest));
}
function watch() {
gulp.watch(paths.scripts.src, scripts);
gulp.watch(paths.styles.src, styles);
gulp.watch(paths.html.src, html);
gulp.watch(paths.images.src, images);
gulp.watch(paths.ico.src, ico);
}
var build = gulp.series(
clean,
gulp.parallel(styles, scripts, html, images, ico)
);
exports.clean = clean;
exports.styles = styles;
exports.scripts = scripts;
exports.html = html;
exports.watch = watch;
exports.images = images;
exports.ico = ico;
exports.build = build;
exports.default = build;