-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuse.js
More file actions
102 lines (81 loc) · 2.35 KB
/
fuse.js
File metadata and controls
102 lines (81 loc) · 2.35 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Imports
*/
const path = require('path');
const express = require('express');
const { FuseBox, RawPlugin, CSSPlugin, QuantumPlugin, WebIndexPlugin, EnvPlugin, Sparky } = require("fuse-box");
/*
* Config
*/
const projectName = "react-renderer-test";
const PageTitle = "React Renderer Test";
const sourceMapStyle = { inline: false };
/*
* No need to adjust anything below this line
*/
const BUILD = {
PRODUCTION: "production",
TEST: "test",
DEV: "dev",
DEV_PRODUCTION: "dev:production",
BUILD_DEBUG: "build-debug"
}
const buildType = process.env.BUILD_TYPE;
if(Object.keys(BUILD).map(key => BUILD[key]).indexOf(buildType) === -1) {
console.error(`unknown build type! [${buildType}]`);
process.exit();
}
console.log(`----------- building [${buildType}] --------`);
const isProduction = (buildType === BUILD.PRODUCTION || buildType === BUILD.DEV_PRODUCTION);
if(isProduction) {
process.env.NODE_ENV = "production";
}
/*
* Main Producer
*/
const mainProducer = FuseBox.init({
homeDir: "src",
useTypescriptCompiler : true,
modulesFolder: "temp_modules",
cache: false,
sourceMaps: (isProduction) ? undefined : sourceMapStyle,
output: (isProduction) ? `dist/$name.min.js` : `dist/$name.js`,
plugins: [
RawPlugin([".glsl"]),
WebIndexPlugin({
title: PageTitle,
template: "./src/webpage/index.html",
path: "."
}),
CSSPlugin(),
EnvPlugin({ BUILD_TYPE: buildType, NODE_ENV: isProduction ? "production" : process.env.NODE_ENV}),
(isProduction) && QuantumPlugin({
removeUseStrict: false,
bakeApiIntoBundle: projectName,
treeshake: true,
uglify: true,
target: "browser"
})
],
target: "browser",
});
const mainBundle = mainProducer.bundle(projectName);
switch(buildType) {
case BUILD.TEST:
mainBundle.test("[tests/**/**.test.ts]");
break;
default:
mainBundle.instructions(`> app/Main.ts`);
break;
}
/*
* Run Fuse
*/
if (buildType === BUILD.DEV || buildType === BUILD.DEV_PRODUCTION) {
mainBundle.watch();
mainProducer.dev({ open: true }, server => {
const app = server.httpServer.app;
app.use("/static/", express.static(path.resolve("./src/webpage/static")));
});
}
mainProducer.run();