-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathwebpack.config.js
106 lines (104 loc) · 2.48 KB
/
webpack.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
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const path = require("path");
const webpack = require("webpack");
const public = path.join(__dirname, "wallet_ui", "public");
const dist = path.join(__dirname, "dist");
module.exports = {
entry: {
index: path.join(__dirname, "wallet_ui/index.tsx"),
},
output: {
filename: "[name].js",
path: dist,
},
mode: "production",
module: {
rules: [
{ test: /\.tsx?$/, loader: "ts-loader" },
{
exclude: /node_modules/,
test: /\.css$/,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
],
},
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
"style-loader",
// Translates CSS into CommonJS
"css-loader",
// Compiles Sass to CSS
"sass-loader",
],
},
],
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
test: /\.[tj]s(\?.*)?$/i,
terserOptions: {
format: {
comments: false,
},
},
}),
],
splitChunks: {
chunks: "async",
minSize: 20000,
minRemainingSize: 0,
maxSize: 250000,
minChunks: 1,
maxAsyncRequests: 30,
maxInitialRequests: 30,
enforceSizeThreshold: 50000,
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10,
reuseExistingChunk: true,
},
default: {
reuseExistingChunk: true,
minChunks: 2,
priority: -20,
},
},
},
},
resolve: {
extensions: [".js", ".ts", ".jsx", ".tsx"],
fallback: {
assert: require.resolve("assert/"),
buffer: require.resolve("buffer/"),
events: require.resolve("events/"),
stream: require.resolve("stream-browserify/"),
util: require.resolve("util/"),
},
},
plugins: [
new webpack.ProvidePlugin({
Buffer: [require.resolve("buffer/"), "Buffer"],
process: require.resolve("process/browser"),
}),
new CopyPlugin({
patterns: [{ from: public, to: path.join(__dirname, "dist") }],
}),
new HtmlWebpackPlugin({
template: "./wallet_ui/index.html",
filename: "index.html",
chunks: ["index"],
}),
],
};