forked from microsoft/charticulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
106 lines (104 loc) · 2.59 KB
/
webpack.config.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
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
103
104
105
106
const webpack = require("webpack");
const childProcess = require("child_process");
const { version } = require("./package.json");
let revision = "unknown";
try {
revision = childProcess
.execSync("git rev-parse HEAD")
.toString()
.trim();
} catch (e) {}
module.exports = (env, { mode }) => {
if (mode == null) {
mode = "production";
}
const plugins = [
new webpack.DefinePlugin({
CHARTICULATOR_PACKAGE: JSON.stringify({
version,
revision,
buildTimestamp: new Date().getTime()
}),
"process.env": {
NODE_ENV: JSON.stringify(mode)
}
})
];
return [
{
// devtool: "eval",
entry:
mode == "production"
? {
app: "./dist/scripts/app/index.js"
}
: {
app: "./dist/scripts/app/index.js",
test: "./dist/scripts/tests/test_app/index.js"
},
output: {
filename: "[name].bundle.js",
path: __dirname + "/dist/scripts",
// Export the app as a global variable "Charticulator"
libraryTarget: "var",
library: "Charticulator"
},
resolve: {
alias: {
resources: __dirname + "/resources"
}
},
plugins
},
{
// devtool: "eval",
entry: {
about: "./dist/scripts/about.js"
},
output: {
filename: "[name].bundle.js",
path: __dirname + "/dist/scripts"
},
plugins
},
{
entry: {
worker: "./dist/scripts/worker/worker_main.js"
},
output: {
filename: "[name].bundle.js",
path: __dirname + "/dist/scripts"
},
resolve: {
alias: {
resources: __dirname + "/resources"
}
},
plugins
},
{
entry: {
container: "./dist/scripts/container/index.js"
},
output: {
filename: "[name].bundle.js",
path: __dirname + "/dist/scripts",
// Export the app as a global variable "Charticulator"
libraryTarget: "var",
library: "CharticulatorContainer"
},
resolve: {
alias: {
resources: __dirname + "/resources",
react: "preact-compat",
"react-dom": "preact-compat",
// Not necessary unless you consume a module using `createClass`
"create-react-class": "preact-compat/lib/create-react-class",
// Not necessary unless you consume a module requiring `react-dom-factories`
"react-dom-factories": "preact-compat/lib/react-dom-factories"
}
},
plugins
}
];
};