-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
50 lines (41 loc) · 1.36 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
const gulp = require('gulp-param')(require('gulp'), process.argv);
const sass = require("gulp-sass");
const rename = require("gulp-rename");
const uglify = require("gulp-uglify");
const webpack2 = require("webpack");
const webpack = require('webpack-stream');
const gulpif = require("gulp-if");
const zip = require("gulp-zip");
const SASS_RESOURCES = [
"sass/*.scss"
];
const JS_RESOURCES = [
"src/*.js"
];
const SASS_CONFIG = {
outputStyle: "compressed"
};
gulp.task("default", ["build-css", "build-js"]);
gulp.task("build-css", function() {
return gulp.src(SASS_RESOURCES)
.pipe(sass(SASS_CONFIG))
.pipe(rename("toast-controller.min.css"))
.pipe(gulp.dest("dist/css/"));
});
gulp.task("build-js", function(production) {
return gulp.src(JS_RESOURCES)
.pipe(webpack(require("./webpack.config.js"), webpack2))
.pipe(gulpif(production, uglify()))
.pipe(gulp.dest("dist/js/"));
});
gulp.task("build-release", ["build-css", "build-js"], function() {
const packageFile = require("./package.json");
const version = packageFile.version;
return gulp.src(["dist/*", "dist/**/*"])
.pipe(zip(`toast-controller_v${version}.zip`))
.pipe(gulp.dest("releases/"));
});
gulp.task("watch", function() {
gulp.watch([SASS_RESOURCES], ["build-css"]);
gulp.watch([JS_RESOURCES], ["build-js"]);
});