-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (60 loc) · 1.71 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
const { series, src, dest, watch } = require("gulp");
const browserSync = require("browser-sync");
const del = require("del");
const cache = require("gulp-cache");
const sass = require("gulp-sass")(require("sass"));
const autoprefixer = require("gulp-autoprefixer");
const sourcemaps = require("gulp-sourcemaps");
function browser_sync(done) {
browserSync.init({
server: { baseDir: "./src" },
open: false,
ui: false,
});
done();
}
function html() {
return src("src/*.html").pipe(dest("dist"));
}
function images() {
return src("src/assets/images/**/*.+(png|jpg|gif|svg)").pipe(
dest("dist/assets/images")
);
}
function scss() {
return src("src/assets/scss/**/*.scss")
.pipe(
sass({
outputStyle: "expanded",
includePaths: ["node_modules/gerillass/scss"],
}).on("error", sass.logError)
)
.pipe(autoprefixer({ cascade: true }))
.pipe(sourcemaps.write())
.pipe(dest("src/assets/css"))
.pipe(browserSync.stream());
}
function css() {
return src("src/assets/css/**/*.css").pipe(dest("dist/assets/css/"));
}
function js() {
// The ordering is very important here!
// First it moves all the js files
// Second it overwrites the "scripts.js" file with the transpiled one
return src("src/assets/js/**/*.js").pipe(dest("dist/assets/js/"));
}
// Deletes the dist folder
function clean_dist() {
return del("./dist");
}
// Cleans the cache
function clear_cache(done) {
return cache.clearAll(done);
}
function watch_files(done) {
watch("src/**/*.scss", scss);
watch("src/**/*.html", browserSync.reload);
done();
}
exports.start = series(clear_cache, browser_sync, scss, watch_files);
exports.build = series(clean_dist, js, scss, css, images, html);