-
Notifications
You must be signed in to change notification settings - Fork 4
/
fuse.js
72 lines (66 loc) · 1.39 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const { src, task, context, bumpVersion } = require("fuse-box/sparky");
const { FuseBox, QuantumPlugin, CSSPlugin, SassPlugin, WebIndexPlugin } = require("fuse-box");
task("default", async context => {
await context.clean();
await context.development();
});
task("dist", async context => {
await context.clean();
await context.dist();
});
context(
class {
getConfig() {
return FuseBox.init({
homeDir: "src",
target: "browser@es5",
hash: this.isProduction,
output: "dist/$name.js",
plugins: [
[SassPlugin(), CSSPlugin()],
WebIndexPlugin({
template: "src/index.html"
}),
this.isProduction &&
QuantumPlugin({
css: true,
uglify: true
})
]
});
}
async clean() {
await src("./dist")
.clean("dist/")
.exec();
}
async prepareDistFolder() {
await bumpVersion("package.json", { type: "patch" });
await src("./package.json")
.dest("dist/")
.exec();
}
dist() {
this.isProduction = true;
const fuse = this.getConfig();
fuse.dev({ fallback: "index.html" });
fuse
.bundle("demo")
.splitConfig({
dest: "/chunks/"
})
.instructions(">app.tsx");
return fuse.run();
}
development() {
const fuse = this.getConfig();
fuse.dev({ fallback: "index.html" });
fuse
.bundle("demo")
.hmr()
.instructions(">app.tsx")
.watch();
return fuse.run();
}
}
);