-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
84 lines (83 loc) ยท 1.9 KB
/
webpack.config.prod.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
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
module.exports = {
mode: 'production',
entry: [
'@babel/polyfill',
'./public/index.js'
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_module/,
use: {
loader: "babel-loader"
}
},
{
test: /\.html$/,
use: [
{
loader: "html-loader",
options: { minimize: true }
}
]
},
{
// write image files under 10k to inline or copy image files over 10k
test: /\.(jpg|jpeg|gif|png|svg|ico)?$/,
use: [
{
loader: 'url-loader',
options: {
limit: 10000,
fallback: 'file-loader',
name: 'images/[name][hase:8].[ext]',
},
},
],
},
{
// write files under 10k to inline or copy files over 10k
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 10000,
fallback: 'file-loader',
name: 'fonts/[name].[ext]',
},
},
],
}
]
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all'
}
}
}
},
plugins: [
new HtmlWebpackPlugin({
template: "./public/index.html",
favicon: './public/favicon.ico',
filename: "index.html"
}),
new BundleAnalyzerPlugin(),
new CleanWebpackPlugin()
],
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].[chunkhash].bundle.js'
}
}