-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
46 lines (41 loc) · 973 Bytes
/
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
const WorkerPlugin = require('worker-plugin');
const path = require('path');
const EXAMPLES = [
'basic',
'character',
'lod',
'maze',
'physics',
'splitscreen',
'terrain',
];
function buildAllExamples() {
const buildRules = [];
EXAMPLES.forEach((dir) => buildRules.push(buildSpecificExample(dir)));
return buildRules;
}
function buildSpecificExample(dir) {
const rule = {
entry: `./examples/${dir}/index.js`,
plugins: [new WorkerPlugin()],
output: {
filename: 'build.js',
path: path.resolve(__dirname, `examples/${dir}/`),
},
devtool: 'eval-source-map',
};
return rule;
}
function buildWebpackRules() {
let specificExample = null;
process.argv.forEach((argv) => {
if (argv.indexOf('example') > -1) {
specificExample = argv.split('=')[1];
}
});
if (specificExample) {
return buildSpecificExample(specificExample);
}
return buildAllExamples();
}
module.exports = buildWebpackRules();