-
Notifications
You must be signed in to change notification settings - Fork 54
/
gulpfile.mjs
113 lines (99 loc) · 2.76 KB
/
gulpfile.mjs
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
106
107
108
109
110
111
112
113
/*jslint node: true, for */
"use strict";
import gulp from "gulp";
import dartSass from "sass";
import gulpSass from "gulp-sass";
import babel from "gulp-babel";
import autoprefixer from "gulp-autoprefixer";
import cssCompressor from "gulp-csso";
import terser from "gulp-terser";
import eslint from "gulp-eslint";
import saveLicense from "uglify-save-license";
import browserSyncPackage from "browser-sync";
import concat from "gulp-concat";
const browserSync = browserSyncPackage.create();
const sass = gulpSass(dartSass);
const browserChoice = "default";
/**
* Build the demo Sass styles
*/
export 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
*/
export 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
*/
export 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"));
}
/**
* Lint ES6
*/
export function lintEs6() {
return gulp.src("dev/simplyCountdown.js")
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
/**
* Lint without breaking
*/
export function lintNoBreakEs6() {
return gulp.src("dev/simplyCountdown.js")
.pipe(eslint())
.pipe(eslint.format());
}
/**
* Reload Browser
*/
export function reload(done) {
browserSync.reload();
done();
}
/**
* Serve with BrowserSync
*/
export 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));
}
// Default Task
export default gulp.series(buildScssDemo, buildScssThemes, lintNoBreakEs6, buildEs6, serve);
// Serve Task
export const serveTask = gulp.series(buildScssDemo, buildScssThemes, lintNoBreakEs6, buildEs6, serve);
// Build Task
export const build = gulp.series(buildScssDemo, buildScssThemes, lintEs6, buildEs6);