-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfuse.js
75 lines (61 loc) · 1.53 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
const {
FuseBox,
QuantumPlugin,
WebIndexPlugin,
Sparky
} = require('fuse-box')
let fuse; let bundle
let isProduction = true
// we can change the target when making a seperate bundle
let target = 'browser'
// bundle name needs to be changed too (as we are making an isolate build and
// and we need to bundle the API into it
let bundleName = 'es5'
let instructions = '> index.js'
Sparky.task('config', () => {
fuse = FuseBox.init({
homeDir: 'src',
// globals: { 'default': '*' }, // we need to expore index in our bundles
output: 'dist/$name.js',
target,
plugins: [
WebIndexPlugin(),
isProduction && QuantumPlugin({
containedAPI: true,
ensureES5: false,
uglify: true,
bakeApiIntoBundle: bundleName
})
]
})
bundle = fuse.bundle(bundleName).instructions(instructions)
})
Sparky.task('clean', () => {
return Sparky.src('dist/').clean('dist/')
})
Sparky.task('copy-src', () => Sparky.src('./**', {
base: './src'
}).dest('dist/'))
Sparky.task('copy-pkg', () => Sparky.src('./package.json').dest('dist/'))
Sparky.task('dev', ['clean'], () => {
bundleName = 'app'
instructions = '> index.js'
})
Sparky.task('dist-es5', async () => {
isProduction = true
// isProduction = false;
bundleName = 'es5'
instructions = '> index.js'
await Sparky.resolve('config')
await fuse.run()
})
Sparky.task('dist', ['clean', 'dist-es5'], () => {
})
// Development
Sparky.task('default', ['dev', 'config'], () => {
fuse.dev()
bundle
.hmr()
.watch()
fuse.run()
})