-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfuse.js
142 lines (124 loc) · 3.63 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
const {
FuseBox,
SassPlugin,
CSSPlugin,
WebIndexPlugin,
Sparky,
QuantumPlugin,
} = require("fuse-box");
const updateNotifier = require('update-notifier');
const pkg = require('./package.json');
// load
const TypeHelper = require('fuse-box-typechecker').TypeHelper;
// Async check (worker)
const testAsync = TypeHelper({
tsConfig: '../tsconfig.json',
basePath: './src',
name: 'Test async'
});
const testExampleAsync = TypeHelper({
tsConfig: './tsconfig.json',
basePath: './example',
name: 'Test async'
});
const {runCLI} = require("jest");
let fuse, app, vendor, isProduction;
Sparky.task("config-dev", () => {
const dist = isProduction ? "dist" : "example/dist";
fuse = FuseBox.init({
// alias: { 'react': 'preact-compact', 'react-dom': 'preact-compact' },
homeDir: "src",
tsConfig: "tsconfig.json",
package: {
name: 'react-select-item',
main: 'index.ts'
},
globals: { "react-select-item": "*" },
output: `${dist}/$name.js`,
sourceMaps: true,
plugins: [
[
SassPlugin(),
CSSPlugin({
group: "styles.css",
outFile: `${dist}/styles.css`
})
],
QuantumPlugin({
target: 'npm',
globalRequire: false,
bakeApiIntoBundle : 'react-select-item',
uglify: false
})
]
});
app = fuse.bundle("react-select-item").instructions("> [index.ts] + tslib + fuse-box-css");
testAsync.runAsync();
});
Sparky.task("config-example", () => {
fuse = FuseBox.init({
// globals: { "react-select-item": "../dist/react-select-item.js" },
alias: { 'react-select-item': './dist/react-select-item.js' },
target: "browser",
homeDir: "example",
tsConfig: "example/tsconfig.json",
output: "build/$name.js",
sourceMaps: true,
useJsNext: ["react", "react-dom"],
polyfillNonStandardDefaultUsage: ["react", "react-dom"],
plugins: [
WebIndexPlugin({
template: "example/index.html",
title: "RSI example",
target: "index.html"
}),
CSSPlugin({
group: "styles.css",
outFile: "build/styles.css"
})
]
});
vendor = fuse.bundle("vendor").instructions("~/example.tsx");
app = fuse.bundle("app").instructions(" > example.tsx");
testExampleAsync.runAsync();
});
Sparky.task("check-updates", () => {
updateNotifier({pkg}).notify();
});
Sparky.task("dev", ["clean", "config-dev", "check-updates"], () => {
fuse.dev({
root: "dist",
port: 8080,
httpServer: false,
});
// add dev instructions
app.watch().hmr();
return fuse.run();
});
Sparky.task("example", ["config-example"], () => {
fuse.dev({
root: "build"
});
// add dev instructions
app.watch().hmr();
return fuse.run();
});
Sparky.task("tests:watch", () => {
runCLI({watchAll: true}, ["src"]);
});
Sparky.task("tests", () => {
runCLI({ci: true}, ["src"]);
});
Sparky.task("clean", () => Sparky.src("dist/").clean("dist/"));
Sparky.task("clean-example", () => Sparky.src("build/").clean("build/"));
Sparky.task("prod-env", ["clean"], () => {
isProduction = true
});
Sparky.task("dist", ["prod-env", "config-dev"], () => {
// comment out to prevent dev server from running (left for the demo)
// fuse.dev({
// port: 8080,
// httpServer: false,
// });
return fuse.run();
});