-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack_prod.config.js
executable file
·79 lines (78 loc) · 2.1 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
var path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
const zlib = require("zlib")
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
module.exports = {
mode: "production",
entry: "./src/main.tsx",
output: {
filename: "bundle.js",
publicPath: '/lastfm-typed/',
path: path.resolve(__dirname, "dist")
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".json"],
fallback: {
"crypto": require.resolve("crypto-browserify"),
"buffer": require.resolve("buffer"),
"stream": require.resolve("stream-browserify"),
}
},
module: {
rules: [
{ test: /\.scss$/, use: [ "style-loader", "css-loader", "sass-loader" ] },
{ test: /\.png/, type: 'asset/resource' },
{
test: /\.(js|jsx|tsx|ts)$/,
exclude: /(node_modules|bower_components)/,
loader: "babel-loader",
options: {
presets: [
["@babel/preset-env", {
corejs: 3,
targets: "last 2 versions, not dead",
useBuiltIns: "usage"
}],
"@babel/preset-typescript",
"@babel/preset-react"
],
plugins: [
"@babel/plugin-syntax-dynamic-import"
]
}
},
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 9000,
publicPath:'/lastfm-typed/',
historyApiFallback: true,
},
optimization: {
minimizer: [new TerserPlugin({})],
},
plugins: [
new HtmlWebpackPlugin({
template: 'public/index.html',
}),
new CompressionPlugin({
filename: "[path][base].br",
algorithm: "brotliCompress",
test: /\.(js|css|html|svg)$/,
compressionOptions: {
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]: 11,
},
},
threshold: 10240,
minRatio: 0.8,
deleteOriginalAssets: false,
}),
new BundleAnalyzerPlugin()
],
};