-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
69 lines (63 loc) · 1.37 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
/** @format */
const path = require('path');
const mode = process.env.NODE_ENV;
const debugBuild = mode === 'development';
const HtmlWebpackPlugin = require('html-webpack-plugin');
let outputPath;
if (debugBuild) {
outputPath = path.resolve(__dirname, 'dist/debug');
} else {
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',
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
options: { minimize: !debugBuild },
},
],
},
];
const plugins = [];
if (debugBuild)
plugins.push(
new HtmlWebpackPlugin({
title: 'Demo debug',
filename: 'index.html',
})
);
const config = {
mode,
entry: [path.resolve(__dirname, './src/bootstrap.js')],
output: {
path: outputPath,
filename: 'app_name.js',
library: 'app_name',
libraryTarget: 'umd',
umdNamedDefine: true,
},
module: {
rules: rules,
},
devServer: {
port: 8000,
hot: true,
},
plugins: plugins,
};
if (debugBuild) config.devtool = 'source-map';
return config;
};