forked from VCityTeam/UD-Viz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
50 lines (45 loc) · 1.1 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
/** @format */
const path = require('path');
const mode = process.env.NODE_ENV;
const debugBuild = mode === 'development';
let outputPath;
let devTool;
if (debugBuild) {
devTool = 'source-map';
outputPath = path.resolve(__dirname, 'dist/debug');
} else {
devTool = 'none';
outputPath = path.resolve(__dirname, 'dist/release');
}
module.exports = (env) => {
const rules = [
{
// We also want to (web)pack the style files:
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.json$/,
include: [path.resolve(__dirname, 'src')],
loader: 'raw-loader',
},
];
const entry = process.env.npm_config_entry || './src/index.js';
const output = process.env.npm_config_output || 'udv';
console.log('Build from ', entry, ' to ', outputPath + '/' + output);
return {
mode,
entry: path.resolve(__dirname, entry),
devtool: devTool,
output: {
path: outputPath,
filename: output + '.js',
library: output + '',
libraryTarget: 'umd',
umdNamedDefine: true,
},
module: {
rules: rules,
},
};
};