-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuse.js
More file actions
80 lines (65 loc) · 1.91 KB
/
fuse.js
File metadata and controls
80 lines (65 loc) · 1.91 KB
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, WebIndexPlugin, QuantumPlugin, CSSPlugin } = require('fuse-box');
const { src, task, exec, context } = require('fuse-box/sparky');
// Context availible for all tasks
context(class {
getConfig() {
return FuseBox.init({
homeDir: 'src',
target: 'browser@es5',
hash: this.isProduction,
output: 'dist/$name.js',
cache: !this.isProduction,
sourceMaps: !this.isProduction,
// Shortcut for styled directory
// Additional tsconfig paths and jest moduleNameMapper required
alias: {
"@styles": "~/styles/"
},
plugins: [
WebIndexPlugin({
template: 'public/index.html',
title: 'React TypeScript Quickstart'
}),
CSSPlugin(),
this.isProduction && QuantumPlugin({
polyfills: ['Promise'],
treeshake: true,
uglify: true
})
]
});
}
createBundle(fuse) {
// Creates vendor libs bundle
fuse.bundle('vendor').instructions('~ index.tsx');
// Project files bundle
const app = fuse.bundle('app');
if (!this.isProduction) {
app.hmr();
app.watch();
}
app.instructions('> [index.tsx]');
return app;
}
});
// Removing dist directory
task('clean', () => src('dist').clean('dist').exec());
// Moving content of /public directory to /dist
task('copy', () => src('**/**.**', { base: 'public' }).dest('dist').exec());
// Default task, ran when no other is specified
task('default', ['clean', 'copy'], async context => {
const fuse = context.getConfig();
fuse.dev({
open: true,
port: 5000
});
context.createBundle(fuse);
await fuse.run();
});
// Production build task with all optimizations enabled, such us uglify and hashed filenames
task('build', ['clean', 'copy'], async context => {
context.isProduction = true;
const fuse = context.getConfig();
context.createBundle(fuse);
await fuse.run();
});