-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.cjs
79 lines (75 loc) · 1.88 KB
/
webpack.config.cjs
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
70
71
72
73
74
75
76
77
78
79
/* eslint-disable import/no-extraneous-dependencies */
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const env = process.env.NODE_ENV || 'development';
module.exports = {
mode: env,
entry: './src/ui/bootstrap.jsx',
output: {
path: path.join(__dirname, 'public'),
filename: 'redota-[name]-[chunkhash:8].js',
},
resolve: {
extensions: ['.js'],
fallback: {
buffer: require.resolve('buffer/'),
},
},
devtool: env === 'development' ? 'inline-cheap-source-map' : false,
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
dotaconstants: {
name: 'dotaconstants',
test: /[\\/]node_modules[\\/]dotaconstants[\\/]/,
},
protobuf: {
name: 'protobuf',
test: /[\\/]dota[\\/]compiled.cjs|[\\/]node_modules[\\/]@?protobufjs/,
},
vendor: {
name: 'vendor',
test: /[\\/]node_modules[\\/](?!dotaconstants|(?:@?protobufjs))/,
},
},
},
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new HtmlWebpackPlugin({
hash: true,
inject: true,
template: './src/ui/index.html',
}),
],
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.worker\.js$/,
loader: 'worker-loader',
options: {
filename: (pathData) => {
let { name } = pathData.chunk;
name = name.replace('.worker', '');
name = name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
return `redota-${name}-[chunkhash:8].worker.js`;
},
},
},
],
},
devServer: {
static: {
directory: path.join(__dirname, 'public'),
},
},
};