-
Notifications
You must be signed in to change notification settings - Fork 52
/
gulpfile.js
105 lines (93 loc) · 2.62 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*jslint node: true, for */
"use strict";
const gulp = require("gulp");
const sass = require("gulp-sass");
const babel = require("gulp-babel");
const autoprefixer = require("gulp-autoprefixer");
const cssCompressor = require("gulp-csso");
const terser = require("gulp-terser");
const eslint = require("gulp-eslint");
const saveLicense = require("uglify-save-license");
const browserSync = require("browser-sync").create();
const concat = require("gulp-concat");
const browserChoice = "default";
/**
* Build the demo sass styles
*/
function buildScssDemo() {
return gulp.src("css/scss/demo.scss")
.pipe(sass({
precision: 10
}).on("error", sass.logError))
.pipe(autoprefixer())
.pipe(cssCompressor({
restructure: false
}))
.pipe(gulp.dest("css"));
}
/**
* Build the themes sass styles
*/
function buildScssThemes() {
return gulp.src("css/scss/simplyCountdown.theme.*.scss")
.pipe(sass({
precision: 10
}).on("error", sass.logError))
.pipe(autoprefixer())
.pipe(cssCompressor({
restructure: false
}))
.pipe(gulp.dest("css"));
}
/**
* Transpile the lib from es6 to es5
*/
function buildEs6() {
return gulp.src("dev/simplyCountdown.js")
.pipe(concat("simplyCountdown.min.js"))
.pipe(babel({
presets: ["@babel/env"]
}))
.pipe(terser({
output: {
comments: saveLicense
}
}))
.pipe(gulp.dest("dist"));
}
function lintEs6() {
return gulp.src("dev/simplyCountdown.js")
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
function lintNoBreakEs6() {
return gulp.src("dev/simplyCountdown.js")
.pipe(eslint())
.pipe(eslint.format());
}
/**
* SERVE
* Take a coffee, relax, and write some code
*/
function reload(done) {
browserSync.reload();
done();
}
function serve() {
browserSync.init({
notify: true,
port: 9000,
reloadDelay: 100,
browser: browserChoice,
server: {
baseDir: "./"
}
});
gulp.watch("dev/**/*.js", gulp.series(lintNoBreakEs6, buildEs6, reload));
gulp.watch("css/scss/**/*", gulp.series(buildScssDemo, buildScssThemes, reload));
gulp.watch("./**/*.html", gulp.series(reload));
}
exports.default = gulp.series(buildScssDemo, buildScssThemes, lintNoBreakEs6, buildEs6, serve);
exports.serve = gulp.series(buildScssDemo, buildScssThemes, lintNoBreakEs6, buildEs6, serve);
exports.build = gulp.series(buildScssDemo, buildScssThemes, lintEs6, buildEs6);