-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.frontend.config.js
More file actions
101 lines (87 loc) · 2.06 KB
/
webpack.frontend.config.js
File metadata and controls
101 lines (87 loc) · 2.06 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const dotenv = require('dotenv')
const path = require('path');
const HTMLWebpackPlugin = require('html-webpack-plugin');
dotenv.config({ path: path.resolve(__dirname, '.env') });
module.exports = {
mode: 'development',
entry: './src/frontend/index.tsx',
module: {
rules: [
// TypeScript + TSX
{
test: /\.(ts|tsx)$/,
use: 'ts-loader',
exclude: /node_modules/,
},
// JavaScript + JSX
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
exclude: /node_modules/,
},
// CSS + Tailwind
{
test: /\.css$/i,
use: [
'style-loader',
'css-loader',
'postcss-loader',
],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.jsx', '.js'],
},
optimization: {
usedExports: true,
sideEffects: true,
minimize: true,
splitChunks: {
chunks: 'all',
minSize: 20000,
cacheGroups: {
react: {
test: /[\\/]node_modules[\\/](react|react-dom|scheduler)[\\/]/,
name: 'react-vendor',
chunks: 'all',
priority: 20,
},
vendors: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all',
priority: 10,
},
},
},
runtimeChunk: 'single',
},
performance: {
maxAssetSize: 2 * 1024 * 1024,
maxEntrypointSize: 2 * 1024 * 1024,
hints: 'warning'
},
output: {
filename: 'js/[name].[contenthash].js',
chunkFilename: 'js/[name].[contenthash].js',
path: path.resolve(__dirname, 'build/frontend/'),
clean: true,
},
devtool: 'source-map',
plugins: [
new HTMLWebpackPlugin({
template: path.resolve(__dirname, './src/frontend/static/index.html'),
minify: false,
}),
],
devServer: {
static: {
directory: path.join(__dirname, './src/frontend/static'),
},
open: true,
compress: true,
port: process.env.APP_FRONTEND_PORT || 3000,
historyApiFallback: true, // to make React Router work without 404
},
};