-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
63 lines (59 loc) · 1.8 KB
/
webpack.config.js
File metadata and controls
63 lines (59 loc) · 1.8 KB
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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const isProd = process.env.NODE_ENV === 'production';
module.exports = {
entry: './src/frontend/index.js',
plugins: [
new HtmlWebpackPlugin({
template: './src/frontend/index.html',
}),
new webpack.EnvironmentPlugin({
SOCKET_URL: 'http://localhost:7080',
}),
new webpack.HashedModuleIdsPlugin(),
new CleanWebpackPlugin(),
],
output: {
path: path.resolve(__dirname, isProd ? 'docs' : 'dev-build'),
filename: '[name].[contenthash].js',
},
// from here: https://medium.com/hackernoon/the-100-correct-way-to-split-your-chunks-with-webpack-f8a9df5b7758
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(
/[\\/]node_modules[\\/](.*?)([\\/]|$)/,
)[1];
return `npm.${packageName.replace('@', '')}`;
},
},
},
},
},
module: {
rules: [
{
test: /\.(js)$/,
use: 'babel-loader',
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
mode: isProd ? 'production' : 'development',
devServer: {
open: true,
port: 7090,
},
};