-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
64 lines (55 loc) · 1.59 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
const gulp = require("gulp");
const del = require("del");
const server = require("browser-sync").create();
const htmlclean = require("gulp-htmlclean");
const cleanCSS = require("gulp-clean-css");
const sass = require("gulp-sass");
const prefix = require("gulp-autoprefixer");
const uglify = require("gulp-uglify");
/////////////////////////////////////////////////////////////////////////////////////////////
// DEVELOPMENT
gulp.task("sass", () => {
gulp
.src("src/scss/*.scss")
.pipe(sass().on("error", e => console.log(e)))
.pipe(gulp.dest("src/css"))
.pipe(server.stream());
});
gulp.task("serve", ["sass"], () => {
server.init({
server: {
baseDir: "src"
}
});
gulp.watch(["src/scss/**/*.scss"], ["sass"]);
gulp.watch(["src/index.html", "src/script/**"]).on("change", server.reload);
});
gulp.task("default", ["serve"]);
/////////////////////////////////////////////////////////////////////////////////////////////
// PRODUCTION
gulp.task("dist:css", () => {
gulp
.src("src/scss/*.scss")
.pipe(
sass({
outputStyle: "compressed"
})
)
.pipe(gulp.dest("dist/css"));
});
gulp.task("dist:html", () => {
gulp
.src("src/index.html")
.pipe(htmlclean())
.pipe(gulp.dest("dist"));
});
gulp.task("dist:images", () =>
gulp.src("src/images/**").pipe(gulp.dest("dist/images/"))
);
gulp.task("dist:js", () =>
gulp
.src("src/script/*.js")
.pipe(uglify())
.pipe(gulp.dest("dist/script/"))
);
gulp.task("build", ["dist:html", "dist:css", "dist:js", "dist:images"]);