This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
fuse.ts
93 lines (92 loc) · 1.91 KB
/
fuse.ts
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import {
BabelPlugin,
CSSPlugin,
EnvPlugin,
FuseBox,
QuantumPlugin,
Sparky,
WebIndexPlugin,
FuseBoxOptions,
CSSResourcePlugin,
CSSModulesPlugin,
CopyPlugin,
SVGPlugin
} from "fuse-box";
let fuse: FuseBox;
const isProd = !process.env.NODE_ENV.includes("dev");
const fuseOptions: FuseBoxOptions = {
homeDir: ".",
output: "./dist/$name.js",
// alias: {
// assets: "./assets/"
// },
// automaticAlias:false,
target: "browser",
// useTypescriptCompiler: true,
plugins: [
[
CSSResourcePlugin({
inline: true,
useOriginalFilenames: true
// dist: "./dist/css"
}),
CSSPlugin({
inject: true,
minify: true
// outFile: file => `dist/${file}`
})
],
SVGPlugin(),
WebIndexPlugin({
template: "./assets/index.html"
}),
CopyPlugin({
files: [".png"],
useDefault: false
}),
isProd &&
QuantumPlugin({
bakeApiIntoBundle: "bundle",
treeshake: true,
uglify: true,
css: true
}),
isProd &&
EnvPlugin({
NODE_ENV: "production"
})
]
};
Sparky.task("clean", async () => {
await Sparky.src("dist")
.clean("dist")
.exec();
});
Sparky.task("config", () => {
fuse = FuseBox.init(fuseOptions);
});
Sparky.task("client", () => {
fuse
.bundle("bundle")
.target("browser")
.watch()
.hmr()
.instructions("> ./src/index.tsx");
});
Sparky.task("clientprd", () => {
fuse
.bundle("bundle")
.target("browser")
.instructions("> ./src/index.tsx");
});
Sparky.task("dev", ["&clean", "&config", "&client"], () => {
fuse.dev({
port: 4444
});
fuse.run();
console.log("DEVELOPMENT BUILD DONE");
});
Sparky.task("prd", ["&clean", "&config", "&clientprd"], () => {
fuse.run();
console.log("PRODUCTION BUILD DONE");
});