-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
53 lines (48 loc) · 1.46 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
const { src, dest, series, parallel } = require('gulp');
const del = require('del');
const rollup = require("rollup");
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const terser = require('rollup-plugin-terser').terser;
function clean(cb) {
del.sync(['dist/**', '!dist']);
cb();
}
function compile(cb) {
const asc = require('assemblyscript/bin/asc');
asc.main([
"index.ts",
"--baseDir", "assembly",
"-b", "../dist/assembly/ballistics.wasm",
"-t", "../dist/assembly/ballistics.wat",
"-j", "../dist/assembly/ballistics.asc.js",
"-O3s", "--converge", "--noAssert",
"--runtime", "full",
"--sourceMap"
], cb);
}
// playcanvas implementation
const prod = true;
function bundle(cb) {
rollup.rollup({
input: 'impl/playcanvas/ballistics.js',
plugins: [resolve(), commonjs(), prod && terser()]
}).then(bundle => {
return bundle.write({
file: 'dist/pc-ballistics/ballistics.min.js',
format: 'iife',
name: 'ballistics',
sourcemap: false
});
}).then(result => {
console.log(result);
cb();
});
}
function copyWasm(cb) {
src('dist/assembly/ballistics.wasm')
.pipe(dest('dist/pc-ballistics'));
cb();
}
exports.build = series(clean, compile, parallel(bundle, copyWasm));
exports.default = series(clean, compile, parallel(bundle, copyWasm));