This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.prod.config.js
115 lines (110 loc) · 2.87 KB
/
webpack.prod.config.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Generated using webpack-cli https://github.com/webpack/webpack-cli
const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const webpack = require('webpack');
module.exports = {
mode: 'production',
resolve: {
fallback: {
'https': false,
'path': false,
},
extensions: ['.js', '*'],
modules: [path.resolve(__dirname, 'js'), 'node_modules', 'src'],
},
entry: path.resolve(__dirname, 'client', 'src', 'index.js'),
output: {
path: path.resolve(__dirname, 'client', 'build'),
filename: '[name].[chunkhash].bundle.js',
},
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
test: /node_modules\/(?!antd\/).*/,
name: 'vendors',
chunks: 'all',
},
// This can be your own design library.
antd: {
test: /node_modules\/(antd\/).*/,
name: 'antd',
chunks: 'all',
},
},
},
runtimeChunk: {
name: 'manifest',
},
},
devServer: {
host: '0.0.0.0',
historyApiFallback: true,
},
plugins: [
new Dotenv({ systemvars: true }),
new CompressionPlugin({
test: /\.js(\?.*)?$/i,
}),
new HtmlWebPackPlugin({
template: path.resolve(__dirname, 'client', 'public', 'index.html'),
filename: './index.html',
title: 'QuickCart',
meta: {
viewport: 'width=device-width, initial-scale=1,viewport-fit=cover, shrink-to-fit=no',
'theme-color': '#42b029',
'apple-mobile-web-app-status-bar-style': '#42b029',
'og:title': 'QuickCart',
'og:description': 'Organize and budget a personal grocery cart for easy shopping',
'content-type': { 'http-equiv': 'content-type', content: 'text/html; charset=UTF-8' },
},
minify: {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
},
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
performance: {
hints: 'warning',
// Calculates sizes of gziped bundles.
assetFilter: function (assetFilename) {
return assetFilename.endsWith('.js.gz');
},
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.css$/,
use: [
'style-loader', 'css-loader',
],
},
{
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
type: 'asset',
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
},
],
},
],
},
};