This repository has been archived by the owner on Jun 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (67 loc) · 1.47 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
const gulp = require("gulp");
const rename = require("gulp-rename");
const sourcemaps = require("gulp-sourcemaps");
const browserSync = require("browser-sync").create();
const sass = require("gulp-sass");
const reload = browserSync.reload;
const uglify = require("gulp-terser");
const src = {
sass: "sass/**/*.scss",
css: "app/css",
html: "app/*.html",
js: "app/js/*.js"
};
// Static Server + watching scss/html files
gulp.task("serve", ["sass", "minify"], () => {
browserSync.init({
server: "./app"
});
gulp.watch(src.sass, ["sass"]);
gulp.watch(src.html).on("change", reload);
});
// Compile sass into CSS
gulp.task("sass", () => {
return gulp
.src(src.sass)
.pipe(
sass({
outputStyle: "compressed"
}).on("error", sass.logError)
)
.pipe(gulp.dest(src.css))
.pipe(
reload({
stream: true
})
);
});
// minify js
gulp.task("minify", () => {
return gulp
.src(src.js)
.pipe(sourcemaps.init())
.pipe(
rename(function(path) {
path.dirname += "";
path.basename += ".min";
path.extname = ".js";
})
)
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest("./app/js"));
});
gulp.task("default", ["serve"]);
gulp.task("build", () =>
gulp
.src([
"app/**/*.html",
"app/**/*.min.js",
"app/**/*.css",
"app/sw.js",
"app/manifest.json",
"app/**/icons/*",
"app/**/img/*"
])
.pipe(gulp.dest("./public/"))
);