forked from basarat/takeme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuse.js
60 lines (56 loc) · 1.48 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
const { FuseBox } = require('fuse-box');
const fsbx = require('fuse-box');
const box = FuseBox
.init({
homeDir: "src",
sourceMap: {
bundleReference: "sourcemaps.js.map",
outFile: "demo/sourcemaps.js.map",
},
outFile: "demo/app.js",
plugins: [
fsbx.EnvPlugin({ NODE_ENV: process.argv[2] }),
!process.argv.includes('client')
&& !process.argv.includes('server')
&& fsbx.UglifyJSPlugin()
]
});
if (process.argv.includes('client')){
box.devServer('>demo/app.tsx', {
port: 8080,
root : './demo'
});
}
else if (process.argv.includes('server')){
box.bundle('>demo/appServer.tsx');
const express = require('express');
const app = express();
app.use('/', (req, res) => {
if ( req.path.indexOf('app.js')!==-1 ) {
res.sendFile(__dirname + '/demo/app.js');
}
else {
res.sendFile(__dirname + '/demo/index.html');
}
});
app.listen(8080, () => console.log('Example app listening on port 8080!'));
}
else {
box.bundle('>demo/app.tsx');
/** Also bundle for server side demo */
FuseBox
.init({
homeDir: "src",
sourceMap: {
bundleReference: "sourcemaps.js.map",
outFile: "demo/awesome/sourcemaps.js.map",
},
outFile: "demo/awesome/appServer.js",
plugins: [
fsbx.EnvPlugin({ NODE_ENV: process.argv[2] }),
!process.argv.includes('client')
&& !process.argv.includes('server')
&& fsbx.UglifyJSPlugin()
]
}).bundle('>demo/appServer.tsx');
}