-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
46 lines (40 loc) · 1.25 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
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
concat = require('gulp-concat'),
terser = require('gulp-terser'),
emcc = require('gulp-emscripten'),
filter = require('gulp-filter')
var siteurl = "https://tumble1999.github.io/mingj/";
var runtime_exports = [
"setValue",
"cwrap",
"ccall"
]
function buildCPP() {
var filterJs = filter(["*.js"], {restore: true});
return gulp.src("cpp/mingj.cpp")
.pipe(emcc(["--no-entry","--bind","-std=c++11","-s WASM=1","-s EXTRA_EXPORTED_RUNTIME_METHODS=['" + runtime_exports.join("','") + "']"]))
.pipe(filterJs)
.pipe(gulp.dest('js'))
.pipe(filterJs.restore)
.pipe(filter(["*.wasm"]))
.pipe(gulp.dest('dist'))
}
function buildJS() {
return gulp.src(["js/module_init.js","js/mingj.js","js/boot/**/*.js", "js/lib/*.js", "js/bin/**/*.js"])
.pipe(plumber())
.pipe(terser({
warnings: "verbose"
}))
.pipe(concat('mingj.min.js'))
.pipe(gulp.dest('dist'))
}
function buildUS() {
return gulp.src(["js/header.user.js", "dist/mingj.min.js", "js/footer.user.js"])
.pipe(concat('mingj.user.js'))
.pipe(gulp.dest('dist'))
}
gulp.task("build-cpp",buildCPP);
gulp.task('build-js', buildJS);
gulp.task('build-us', buildUS);
gulp.task('build', gulp.series('build-cpp','build-js', 'build-us'));