-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathwebpack.config.prod.js
59 lines (57 loc) · 1.35 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
// shared config (dev and prod)
const { resolve } = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
module.exports = {
mode: "production",
devtool: "source-map",
entry: resolve(__dirname, "./src/index.tsx"),
output: {
filename: "js/bundle.[chunkhash].min.js",
path: resolve(__dirname, "./build"),
publicPath: "/",
},
resolve: {
alias: {
Src: resolve(__dirname, "./src/"),
},
extensions: [".ts", ".tsx", ".js", ".jsx"],
},
module: {
rules: [
{
test: [/\.jsx?$/, /\.tsx?$/],
use: ["babel-loader"],
exclude: /node_modules/,
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.(scss|sass)$/,
use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
use: [
"file-loader?hash=sha512&digest=hex&name=img/[chunkhash].[ext]",
"image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false",
],
},
],
},
plugins: [
new CompressionPlugin({
exclude: /.map$/
}),
new HtmlWebpackPlugin({ template: "src/index.html.ejs" }),
new CopyPlugin({
patterns: [{ from: resolve(__dirname, "public/"), to: "." }],
}),
],
performance: {
hints: false,
},
};