forked from ava-cassiopeia/simple-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
89 lines (75 loc) · 2.21 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
const gulp = require("gulp");
const sass = require("gulp-sass")(require("node-sass"));
const webpackStream = require("webpack-stream");
const webpack2 = require("webpack");
const uglify = require("gulp-uglify");
const zip = require("gulp-zip");
const clean = require("gulp-clean");
const args = require("really-simple-args")();
const OUTPUT_DIR = "dist";
const JS_SRCS = ["src/javascript/*.js", "src/javascript/**/*.js"];
const CSS_SRCS = ["src/sass/*.scss", "src/sass/**/*.scss"];
/**
* =============================================================================
* | DEV BUILDS
* =============================================================================
*/
function buildCSS() {
return gulp.src(CSS_SRCS)
.pipe(sass({
outputStyle: "compressed"
}))
.pipe(gulp.dest(`${OUTPUT_DIR}/css/`));
}
function buildJS() {
return gulp.src(JS_SRCS)
.pipe(webpackStream(require("./webpack.config.js"), webpack2))
.pipe(uglify())
.pipe(gulp.dest(`${OUTPUT_DIR}/js/`));
}
function watch() {
gulp.watch(CSS_SRCS, buildCSS);
gulp.watch(JS_SRCS, buildJS);
}
/**
* =============================================================================
* | RELEASES
* =============================================================================
*/
function buildRelease() {
let version = "";
if(args.hasParameter("version")) {
version = args.getParameter("version");
} else {
version = require("./package.json").version;
}
const releaseName = `simple-switch_v${version}.zip`;
return gulp.src(["release/*", "release/**/*"])
.pipe(zip(releaseName))
.pipe(gulp.dest("releases/"));
}
function prepareRelease() {
return gulp.src(["dist/*", "dist/**/*"])
.pipe(gulp.dest("release/"));
}
function prepareReleaseSass() {
return gulp.src(CSS_SRCS)
.pipe(gulp.dest("dist/sass/"));
}
function cleanBuildArtifacts() {
return gulp.src([
"dist/",
"release/",
"releases/"
]).pipe(clean());
}
exports.default = gulp.parallel(buildCSS, buildJS);
exports.buildCSS = buildCSS;
exports.buildJS = buildJS;
exports.watch = watch;
exports.buildRelease = gulp.series(
gulp.parallel(buildCSS, buildJS, prepareReleaseSass),
prepareRelease,
buildRelease,
);
exports.clean = cleanBuildArtifacts;