-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
86 lines (76 loc) · 2.11 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
const gulp = require("gulp"),
concat = require("gulp-concat"),
sass = require("gulp-sass")(require("sass")),
cleanCSS = require("gulp-clean-css"),
minify = require("gulp-minify");
///// Watch for changes /////
async function watch() {
gulp.watch("src/js/services/**/*.js", gulp.series(concatJS));
gulp.watch("src/scss/**/*.scss", gulp.series(compileSASS));
}
/////// CSS ///////
function compileSASS(done) {
gulp
.src("src/scss/styles.scss")
.pipe(
sass({
errLogToConsole: true
})
)
.pipe(gulp.dest("src/css"))
.on("end", done);
}
function minifyCSS() {
return gulp
.src("src/css/styles.css")
.pipe(cleanCSS({ compatibility: "ie8" }))
.pipe(gulp.dest("src/css/minified/"));
}
/// JS ///
function concatJS() {
return gulp
.src(["src/js/services/**/*.js"])
.pipe(concat("scripts.js"))
.pipe(gulp.dest("src/js"));
}
function minifyJS() {
return gulp
.src("src/js/scripts.js")
.pipe(
minify({
noSource: true,
ext: ".js"
})
)
.on("error", function(e) {
console.log(e);
})
.pipe(gulp.dest("src/js/minified"));
}
///// Build deployment files for /////
async function copyFilesToBuild() {
gulp
.src([
"src/index.html",
"src/404.html",
"src/manifest.json",
"src/manifest.json",
"src/browserconfig.xml",
"src/robots.txt",
"README.md"
])
.pipe(gulp.dest("build/"));
gulp.src("src/img/**/*").pipe(gulp.dest("build/img/"));
gulp.src("src/css/minified/styles.css").pipe(gulp.dest("build/css/"));
gulp.src("src/css/fonts/**/*").pipe(gulp.dest("build/css/fonts/"));
gulp.src("src/js/minified/scripts.js").pipe(gulp.dest("build/js/"));
gulp.src("src/js/data.js").pipe(gulp.dest("build/js/"));
}
exports.js = gulp.series(concatJS, minifyJS);
exports.css = gulp.series(compileSASS, minifyCSS);
exports.build = gulp.series(
gulp.series(compileSASS, minifyCSS),
gulp.series(concatJS, minifyJS),
copyFilesToBuild
);
exports.default = gulp.series(concatJS, compileSASS, watch);