forked from 4919/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (59 loc) · 1.61 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
// gulp v4.0.2
const gulp = require("gulp"),
sass = require("gulp-sass"),
uglify = require("gulp-uglify"),
cleanCSS = require("gulp-clean-css"),
plumber = require("gulp-plumber"),
mmq = require("gulp-merge-media-queries");
const cleanCSS_1stSettings =
{ // ref: https://outcloud.blogspot.com/2018/09/Minify-CSS-by-CleanCSS-MergeMediaQuery.html
level: {
1: {
roundingPrecision : 3
},
2: {
removeDuplicateFontRules: true,
removeDuplicateMediaBlocks: true,
removeDuplicateRules: true,
mergeSemantically: true,
removeUnusedAtRules: true,
restructureRules: true
}
}
};
const cleanCSS_2ndSettings =
{
level: {
1: {
all: false,
removeWhitespace: true
}
}
};
gulp.task("sass", function() {
return gulp.src("./src/css/*.scss")
.pipe(plumber())
.pipe(sass())
.pipe(cleanCSS(cleanCSS_1stSettings))
.pipe(mmq())
.pipe(cleanCSS(cleanCSS_2ndSettings))
.pipe(gulp.dest("./docs/css/"));
});
gulp.task("js", function() {
return gulp.src("./src/js/*.js")
.pipe(gulp.dest("./docs/js/"));
// .pipe(uglify())
});
gulp.task("data", function() {
return gulp.src('src/data/**/*.csv')
.pipe(gulp.dest('./docs/data/'));
});
// watch
gulp.task("watch", (done) => {
gulp.watch("./src/js/*.js", gulp.series("js"));
gulp.watch("./src/css/*.scss", gulp.series("sass"));
gulp.watch("./src/data/", gulp.series("data"));
done();
});
// scripts tasks
gulp.task('default', gulp.task('watch'));