This repository has been archived by the owner on Sep 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
/
fuse.js
108 lines (99 loc) · 3.54 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
const npm = require('./package.json');
const app = npm.app;
const { Ng2TemplatePlugin } = require('ng2-fused');
const {
Sparky,
BabelPlugin,
FuseBox,
SassPlugin,
CSSPlugin,
WebIndexPlugin,
TypeScriptHelpers,
JSONPlugin,
HTMLPlugin,
UglifyESPlugin,
RawPlugin,
CopyPlugin,
CSSResourcePlugin,
UglifyJSPlugin
} = require('fuse-box');
const baseOptions = {
homeDir: 'src/',
plugins: [
Ng2TemplatePlugin(),
['*.component.html', RawPlugin()],
['*.component.scss', SassPlugin({ sourceMap: false }), RawPlugin()],
TypeScriptHelpers(),
WebIndexPlugin({
title: app.name,
template: 'src/client/index.html',
bundles: ['js/vendor', 'js/app']
}),
JSONPlugin(),
HTMLPlugin({ useDefault: false })
],
alias: {
"@angular/platform-browser/animations": "@angular/platform-browser/bundles/platform-browser-animations.umd.js",
}
}
const devOptions = Object.assign({
output: `${app.outputDir}/dev/$name.js`,
sourceMaps: { project: true, vendor: true }
}, baseOptions);
const prodOptions = Object.assign({
output: `${app.outputDir}/prod/$name.js`,
sourceMaps: { project: false, vendor: false }
}, baseOptions)
Sparky.task("clean", () => Sparky.src(`${app.outputDir}`).clean(`${app.outputDir}`));
Sparky.task("assets.dev", () => Sparky.src(`./assets/**/*.*`, { base: `./${app.assetParentDir}`}).dest(`./${app.outputDir}/dev`));
Sparky.task("assets.prod", () => Sparky.src(`./assets/**/*.*`, { base: `./${app.assetParentDir}`}).dest(`./${app.outputDir}/prod`));
Sparky.task("build.dev", ["clean", "assets.dev"], () => undefined);
Sparky.task("build.prod", ["clean", "assets.prod"], () => undefined);
Sparky.task("serve.dev.spa", ["clean"], () => {
const fuse = FuseBox.init(devOptions);
fuse.opts = devOptions;
fuse.dev({ port: app.server.port });
fuse.bundle('js/vendor').hmr().instructions(' ~ client/main.ts');
fuse.bundle('js/app')
.instructions(' !> [client/main.ts]')
.watch()
.hmr();
fuse.run()
});
Sparky.task("serve.dev.universal", ["build.dev"], () => {
const fuse = FuseBox.init(devOptions);
fuse.dev({ httpServer: false });
fuse.bundle('js/vendor').instructions(' ~ client/main.ts').watch();
fuse.bundle("js/app").instructions(" !> [client/main.ts]").watch();
fuse.bundle("server").instructions(" > [server/server.ts]")
.watch()
.completed(proc => proc.start())
fuse.run()
});
Sparky.task("serve.prod.universal", ["build.prod"], () => {
const fuse = FuseBox.init(prodOptions);
fuse.dev({ httpServer: false });
fuse.bundle('js/vendor').instructions(' ~ client/main.ts').watch();
fuse.bundle("js/app").instructions(" !> [client/main.ts]").watch();
fuse.bundle("server").instructions(" > [server/server.ts]")
.completed(proc => proc.start())
fuse.run()
});
Sparky.task("serve.prod.min.universal", ["build.prod"], () => {
const fuse = FuseBox.init(prodOptions);
fuse.opts.plugins = [...fuse.opts.plugins, UglifyESPlugin()]
fuse.dev({ httpServer: false });
fuse.bundle('js/vendor').instructions(' ~ client/main.ts');
fuse.bundle("js/app").instructions(" !> [client/main.ts]");
fuse.bundle("server").instructions(" > [server/server.ts]")
.completed(proc => proc.start())
fuse.run()
})
Sparky.task("build.prod.min.universal", ["build.prod"], () => {
const fuse = FuseBox.init(prodOptions);
fuse.opts.plugins = [...fuse.opts.plugins, UglifyESPlugin()]
fuse.bundle('js/vendor').instructions(' ~ client/main.ts');
fuse.bundle("js/app").instructions(" !> [client/main.ts]");
fuse.bundle("server").instructions(" > [server/server.ts]");
fuse.run()
})