This repository has been archived by the owner on May 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
fuse.ts
76 lines (76 loc) · 2.3 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
import { CSSPlugin, FuseBox, FuseBoxOptions, Sparky } from "fuse-box";
import path = require("path");
import TsTransformClasscat from "ts-transform-classcat";
import TsTransformInferno from "ts-transform-inferno";
/**
* Some of FuseBoxOptions overrides by ts config (module, target, etc)
* https://fuse-box.org/page/working-with-targets
*/
let fuse: FuseBox;
const fuseOptions: FuseBoxOptions = {
homeDir: "./src",
output: "dist/$name.js",
sourceMaps: { inline: false, vendor: false },
/**
* Custom TypeScript Transformers (compile Inferno tsx to ts)
*/
transformers: {
before: [TsTransformClasscat(), TsTransformInferno()]
}
};
const fuseClientOptions: FuseBoxOptions = {
...fuseOptions,
plugins: [
/**
* https://fuse-box.org/page/css-resource-plugin
* Compile Sass {SassPlugin()}
* Make .css files modules-like (allow import them like modules) {CSSModules}
* Make .css files modules like and allow import it from node_modules too {CSSResourcePlugin}
* Use them all and bundle with {CSSPlugin}
* */
CSSPlugin()
]
};
const fuseServerOptions: FuseBoxOptions = {
...fuseOptions
};
Sparky.task("clean", () => {
/**Clean distribute (dist) folder */
Sparky.src("dist")
.clean("dist")
.exec();
});
Sparky.task("config", () => {
fuse = FuseBox.init(fuseOptions);
fuse.dev();
});
Sparky.task("test", ["&clean", "&config"], () => {
fuse.bundle("client/bundle").test("[**/**.test.tsx]", null);
});
Sparky.task("client", () => {
fuse.opts = fuseClientOptions;
fuse
.bundle("client/bundle")
.target("browser@esnext")
.watch("client/**")
.hmr()
.instructions("> client/index.tsx");
});
Sparky.task("server", () => {
/**Workaround. Should be fixed */
fuse.opts = fuseServerOptions;
fuse
.bundle("server/bundle")
.watch("**")
.target("server@esnext")
.instructions("> [server/index.tsx]")
.completed(proc => {
proc.require({
// tslint:disable-next-line:no-shadowed-variable
close: ({ FuseBox }) => FuseBox.import(FuseBox.mainFile).shutdown()
});
});
});
Sparky.task("dev", ["&clean", "&config", "&client", "&server"], () => {
fuse.run();
});