This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuse.js
55 lines (47 loc) · 1.52 KB
/
fuse.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
const { UglifyESPlugin } = require("fuse-box/plugins/UglifyESPlugin");
const { UglifyJSPlugin } = require("fuse-box/plugins/UglifyJSPlugin");
const {exec} = require("child_process")
const { FuseBox, WebIndexPlugin, QuantumPlugin,StylusPlugin,CSSPlugin, Sparky } = require("fuse-box");
const { src, task, context, tsc, watch } = require('fuse-box/sparky');
const isProduction = false;
task('default',async context => {
// context.isProduction = true;
const bundleName = "public/javascripts/main"
const fuse = context.getConfig(bundleName);
context.createBundle(fuse,bundleName);
await fuse.run();
});
task('production',async context => {
context.isProduction = true;
const bundleName = "public/javascripts/main"
const fuse = context.getConfig(bundleName);
context.createBundle(fuse,bundleName);
await fuse.run();
});
task('transpile', () => {
exec("tsc --watch")
});
task('runServer', () => {
exec("nodemon dist/app")
});
task('whole',["&transpile","&runServer","default"])
context(class {
getConfig(bundleName) {
return FuseBox.init({
homeDir: "src",
target: 'browser@es5',
output: "$name.bundle.js",
plugins: [
[StylusPlugin(), CSSPlugin()],
this.isProduction && UglifyJSPlugin()
]
})
};
createBundle(fuse,name){
const bundle = fuse.bundle(name).instructions(" > main.ts");
if(!this.isProduction){
bundle.watch();
}
return bundle
}
});