-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.babel.js
63 lines (55 loc) · 1.87 KB
/
gulpfile.babel.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
import gulp from "gulp";
import rimraf from "gulp-rimraf";
import preprocess from "gulp-preprocess";
import cssMin from "gulp-cssmin";
import browserify from "browserify";
import to5ify from "6to5ify";
import streamify from "gulp-streamify";
import source from "vinyl-source-stream";
import scss from "gulp-sass";
import pkg from "./package.json";
const
SOURCE_DIR = `${ __dirname }/src`,
BUILD_DIR = `${ __dirname }/build`,
context = {
package: pkg
};
gulp.task("clean", () => {
return gulp.src(BUILD_DIR, { read: false })
.pipe(rimraf());
});
gulp.task("cls", ["clean"], () => {
return gulp.src(SOURCE_DIR + "/cls/**/*.cls")
.pipe(preprocess({ context: context }))
.pipe(gulp.dest(BUILD_DIR + "/cls"));
});
gulp.task("html", ["clean"], () => {
return gulp.src(SOURCE_DIR + "/static/**/*.html")
.pipe(preprocess({ context: context }))
.pipe(gulp.dest(BUILD_DIR + "/static"));
});
gulp.task("etc", ["clean"], () => {
return gulp.src([
`${ SOURCE_DIR }/static/**/*.*`,
`!${ SOURCE_DIR }/static/js/**/*.*`,
`!${ SOURCE_DIR }/static/scss/**/*.*`,
`!${ SOURCE_DIR }/static/index.html`
])
.pipe(gulp.dest(BUILD_DIR + "/static"));
});
gulp.task("js", ["clean"], () => {
return browserify(`${ SOURCE_DIR }/static/js/index.js`, { debug: true })
.transform(to5ify)
.bundle()
.on(`error`, (err) => { console.error(err); })
.pipe(source("index.js"))
.pipe(streamify(preprocess({ context: context })))
.pipe(gulp.dest(`${ BUILD_DIR }/static/js`));
});
gulp.task("css", ["clean"], () => {
return gulp.src(`${ SOURCE_DIR }/static/scss/index.scss`)
.pipe(scss().on("error", scss.logError))
.pipe(cssMin())
.pipe(gulp.dest(`${ BUILD_DIR }/static/css`));
});
gulp.task("default", ["cls", "html", "js", "css", "etc"]);