forked from fuse-box/fuse-box-vue-seed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuse.js
80 lines (71 loc) · 1.99 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
const {
FuseBox,
VueComponentPlugin,
QuantumPlugin,
HTMLPlugin,
SassPlugin,
CSSPlugin,
CSSResourcePlugin,
WebIndexPlugin,
Sparky
} = require("fuse-box");
let fuse;
let isProduction = false;
Sparky.task("set-prod", () => {
isProduction = true;
});
Sparky.task("clean", () => Sparky.src("./dist").clean("dist/"));
Sparky.task("watch-assets", () => Sparky.watch("./assets", { base: "./src" }).dest("./dist"));
Sparky.task("copy-assets", () => Sparky.src("./assets", { base: "./src" }).dest("./dist"));
Sparky.task("config", () => {
fuse = FuseBox.init({
homeDir: "./src",
output: "dist/$name.js",
//hash: isProduction,
sourceMaps: !isProduction,
useTypescriptCompiler: true,
polyfillNonStandardDefaultUsage: true,
plugins: [
VueComponentPlugin({
style: [
SassPlugin({
importer: true
}),
CSSResourcePlugin(),
CSSPlugin({
group: 'components.css',
inject: 'components.css'
})
]
}),
CSSPlugin(),
WebIndexPlugin({
template: "./src/index.html"
}),
isProduction && QuantumPlugin({
bakeApiIntoBundle: "vendor",
uglify: true,
treeshake: true
}),
]
});
if(!isProduction){
fuse.dev({
open: true,
port: 8080
});
}
const vendor = fuse.bundle("vendor")
.instructions("~ index.js");
const app = fuse.bundle("app")
.instructions("> [index.js]");
if(!isProduction){
app.watch().hmr();
}
})
Sparky.task("default", ["clean", "watch-assets", "config"], () => {
return fuse.run();
});
Sparky.task("dist", [ "clean", "copy-assets", "set-prod", "config"], () => {
return fuse.run();
});