-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
71 lines (70 loc) · 2.4 KB
/
webpack.common.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
70
71
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const Dotenv = require('dotenv-webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
entry: path.resolve(__dirname, 'src', 'index.tsx'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[contenthash].bundle.js',
publicPath: "/",
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
module: {
rules: [
{
test: /\.ts(x?)$/,
loader: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(woff2|woff|eot|ttf|otf)$/,
use: ['file-loader'],
},
{
test: /\.svg$/i,
use: ['@svgr/webpack'],
},
],
},
plugins: [
// Uncomment next line to run bundle analytics on build/run (https://www.npmjs.com/package/webpack-bundle-analyzer)
// new BundleAnalyzerPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'public', 'index.html'),
}),
new Dotenv({
// Loading environment variables from `.env`-file, if present. These variables can be referenced in
// the source code with "process.env.VAR_NAME", and will be replaced at build time.
// Next line also enables loading of environment variables from executing CLI session (for CI/CD purposes).
// System environment variables takes presedence over those loaded from `.env` files.
systemvars: true
})
],
optimization: {
splitChunks: {
chunks: "all",
cacheGroups: {
keycloak: {
test: /[\\/]node_modules[\\/](@react-keycloak|keycloak-js)/,
name: "keycloak"
},
formlibs: {
test: /[\\/]node_modules[\\/](react-hook-form|yup|@hookform)/,
name: "formlibs"
},
vendors: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
priority: -10
}
}
}
},
};