-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
111 lines (90 loc) · 3.78 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
106
107
108
109
110
111
/**
* Gulp Config
* =====================
* Automation task
*
* @contributors: Patryk Rzucidło [@ptkdev] <[email protected]> (https://ptkdev.it)
*
* @license: This code and contributions have 'MIT License'
*
*/
const gulp = require("gulp");
const gulp_concat = require("gulp-concat");
const gulp_sass = require("gulp-sass");
const gulp_minifycss = require("gulp-clean-css");
const gulp_minifyjs = require("gulp-terser");
const gulp_rename = require("gulp-rename");
const gulp_replace = require("gulp-replace");
const version = require("./package.json").version;
gulp.task("build-css", function() {
return gulp.src([`./node_modules/bulma/css/bulma.min.css`, `./node_modules/bulma-extensions/dist/css/bulma-extensions.min.css`, `./node_modules/bulma-extensions/bulma-tagsinput/dist/css/bulma-tagsinput.min.css`, `./client/css/main.scss`, `./client/css/colors.scss`])
.pipe(gulp_concat({path: "./full.min.tmp"}))
.pipe(gulp_sass())
.pipe(gulp_minifycss())
.pipe(gulp_rename("full.min.css"))
.pipe(gulp.dest(`./build/css/`));
});
gulp.task("build-js-popup", function() {
let files = [`./node_modules/bulma-extensions/dist/js/bulma-extensions.min.js`, `./node_modules/bulma-extensions/bulma-tagsinput/dist/js/bulma-tagsinput.min.js`, `./client/js/dom.js`, `./client/js/main.js`, `./client/js/events.js`];
return gulp.src(files)
.pipe(gulp_concat({path: "popup.min.tmp"}))
.pipe(gulp_minifyjs({output: {comments: false}}))
.pipe(gulp_rename("popup.min.js"))
.pipe(gulp.dest(`./build/js/`));
});
gulp.task("build-js-background", function() {
let files = [`./client/js/video.js`];
return gulp.src(files)
.pipe(gulp_concat({path: "video.min.tmp"}))
.pipe(gulp_minifyjs({output: {comments: false}}))
.pipe(gulp_rename("video.min.js"))
.pipe(gulp.dest(`./build/js/`));
});
gulp.task("build-js-options", function() {
let files = [`./client/js/options.js`];
return gulp.src(files)
.pipe(gulp_concat({path: "options.min.tmp"}))
.pipe(gulp_minifyjs({output: {comments: false}}))
.pipe(gulp_rename("options.min.js"))
.pipe(gulp.dest(`./build/js/`));
});
gulp.task("build-js-commands", function() {
let files = [`./client/js/commands.js`];
return gulp.src(files)
.pipe(gulp_concat({path: "commands.min.tmp"}))
.pipe(gulp_minifyjs({output: {comments: false}}))
.pipe(gulp_rename("commands.min.js"))
.pipe(gulp.dest(`./build/js/`));
});
gulp.task("build-html", function() {
let files = [`./client/html/**/*`];
return gulp.src(files)
.pipe(gulp.dest(`./build/`));
});
gulp.task("build-images", function() {
let files = [`./client/images/**/*`];
return gulp.src(files)
.pipe(gulp.dest(`./build/images/`));
});
gulp.task("build-translations", function() {
let files = [`./translations/**/*`];
return gulp.src(files)
.pipe(gulp.dest(`./build/_locales/`));
});
gulp.task("build-manifest", function() {
let files = [`./configs/manifest.json`];
return gulp.src(files)
.pipe(gulp_replace("{{version}}", version))
.pipe(gulp.dest(`./build/`));
});
gulp.task("build-watch", (done) => {
gulp.watch([`./client/css/**/*.scss`]).on("change", gulp.parallel("build-css"));
gulp.watch([`./client/js/**/*.js`]).on("change", gulp.parallel("build-js-popup", "build-js-options", "build-js-commands", "build-js-background"));
gulp.watch([`./client/images/**/*`]).on("change", gulp.parallel("build-images"));
gulp.watch([`./client/html/**/*`]).on("change", gulp.parallel("build-html"));
gulp.watch([`./translations/**/*`]).on("change", gulp.parallel("build-translations"));
gulp.watch([`./configs/**/*`]).on("change", gulp.parallel("build-manifest"));
done();
});
gulp.task("build", gulp.series("build-css", "build-js-popup", "build-js-options", "build-js-commands", "build-js-background", "build-html", "build-images", "build-translations", "build-manifest"));
gulp.task("dev", gulp.parallel("build-watch"));