/
fuse.js
56 lines (48 loc) · 1.21 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
const {
FuseBox,
ReplacePlugin,
UglifyJSPlugin,
WebIndexPlugin
} = require('fuse-box')
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
const isDevelopment = process.env.NODE_ENV === 'development'
const isWatchMode = isDevelopment && process.env.WATCH !== undefined
const isProduction = process.env.NODE_ENV === 'production'
const fuse = FuseBox.init({
homeDir: "ts",
output: "./public/assets/javascript/$name.js",
debug: isDevelopment,
cache: !isProduction,
plugins: [
WebIndexPlugin({
template: 'index.html',
path: '/assets/javascript/',
target: '../../index.html',
})
]
})
if (isWatchMode) {
fuse.dev({
root: './public',
port: 3000,
open: 'http://localhost:3000/'
})
}
const PARTY_BUNDLE = 'party';
const PARTY_API = isDevelopment ? 'http://localhost:3005' : 'https://api.tunage.app'
const app = fuse
.bundle(PARTY_BUNDLE)
.instructions("> main.ts")
.plugin(ReplacePlugin({
'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
'process.env.PARTY_API': `'${process.env.PARTY_API || PARTY_API}'`
}))
if (isProduction) {
app.plugin(UglifyJSPlugin())
}
if (isWatchMode) {
app
.hmr({reload : true})
.watch('ts/**')
}
fuse.run()