forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
87 lines (85 loc) · 2.03 KB
/
webpack.config.js
File metadata and controls
87 lines (85 loc) · 2.03 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const { getIfUtils, removeEmpty } = require('webpack-config-utils')
module.exports = (env) => {
const { ifNotProduction } = getIfUtils(env)
return {
mode: env.production ? 'production' : 'development',
entry: {
main: './src/index.js',
},
output: {
publicPath: '/',
path: path.resolve(__dirname, 'public'),
filename: '[name].[fullhash].js',
},
optimization: {
runtimeChunk: {
name: (entrypoint) => `runtime~${entrypoint.name}`,
},
splitChunks: {
chunks: 'all',
},
},
resolve: removeEmpty({
alias: ifNotProduction({
'react-dom': '@hot-loader/react-dom',
}),
}),
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: './src/html.js',
}),
],
devServer: {
port: 3000,
host: '0.0.0.0',
publicPath: '/',
hot: true,
historyApiFallback: { disableDotRule: true },
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader'],
},
{
test: /manifest.json$/i,
type: 'asset/resource',
generator: {
filename: '[name][ext]',
},
},
{
test: /robots.txt|favicon.ico$/i,
type: 'asset/resource',
generator: {
filename: '[name][ext]',
},
},
{
test: /\.(png|svg|jpe?g|gif)$/i,
type: 'asset/resource',
generator: {
filename: 'images/[name][ext]',
},
},
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
// cache transpilation results to speed up build
cacheDirectory: true,
},
},
},
],
},
}
}