forked from VCityTeam/UD-Viz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
45 lines (40 loc) · 1.08 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
const path = require('path');
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const result = {
entry: './bin/indexExamples.js',
output: {
filename: 'bundle.js',
library: 'udviz',
libraryTarget: 'umd',
umdNamedDefine: true,
},
module: {
rules: [],
},
resolve: {
modules: ['node_modules'],
},
plugins: [],
};
if (process.env.ANALYZE) {
result.plugins.push(new BundleAnalyzerPlugin());
}
// inject css in bundle (show_room and game_browser_template are using css)
result.module.rules.push({
test: /\.css$/,
use: [
'style-loader', // Tells webpack how to append CSS to the DOM as a style tag.
'css-loader', // Tells webpack how to read a CSS file.
],
});
// production or development
if (process.env.NODE_ENV == 'production') {
result.output.path = path.resolve(process.cwd(), './dist/production');
result.mode = 'production';
} else {
result.mode = 'development';
result.devtool = 'source-map';
result.output.path = path.resolve(process.cwd(), './dist/development');
}
module.exports = result;