-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathwebpack.renderer.config.js
More file actions
110 lines (107 loc) · 3.14 KB
/
webpack.renderer.config.js
File metadata and controls
110 lines (107 loc) · 3.14 KB
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
const rules = require("./webpack.rules");
const plugins = require("./webpack.plugins");
const path = require("path");
const isProduction = process.argv[process.argv.indexOf("--mode") + 1] === "production";
rules.push(
{
test: /\.css$/,
use: [{ loader: "style-loader" }, { loader: "css-loader" }, { loader: "postcss-loader" }],
},
{
test: /\.(png|svg|jpg|jpeg|gif|ico)$/i,
type: "asset/resource",
}
);
module.exports = {
module: {
rules,
},
plugins: plugins,
devtool: isProduction ? "source-map" : "eval-cheap-module-source-map",
cache: {
type: "filesystem",
buildDependencies: {
config: [__filename, require.resolve("./webpack.rules"), require.resolve("./webpack.plugins")],
},
},
resolve: {
extensions: [".js", ".ts", ".jsx", ".tsx", ".css"],
fallback: {
http: require.resolve("stream-http"),
os: require.resolve("os-browserify/browser"),
https: require.resolve("https-browserify"),
path: require.resolve("path-browserify"),
},
alias: {
"@": path.resolve(__dirname, "./"),
},
},
optimization: isProduction
? {
splitChunks: {
chunks: "all",
maxInitialRequests: 20,
maxAsyncRequests: 20,
cacheGroups: {
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
vendor: {
test: /[\/]node_modules[\/]/,
name: "renderer-vendors",
chunks: "all",
priority: 10,
enforce: true,
},
handsontable: {
test: /[\/]node_modules[\/](@handsontable|handsontable)[\/]/,
name: "renderer-handsontable",
chunks: "async",
priority: 20,
enforce: true,
},
reactIcons: {
test: /[\/]node_modules[\/]react-icons[\/]/,
name: "renderer-react-icons",
chunks: "async",
priority: 15,
},
flowbite: {
test: /[\/]src[\/]flowbite[\/]/,
name: "renderer-flowbite",
chunks: "async",
priority: 8,
},
viewer: {
test: /[\/]src[\/]components[\/]viewer[\/]/,
name: "renderer-viewer",
chunks: "async",
priority: 12,
},
skillsViewer: {
test: /[\/]src[\/]components[\/]skillsViewer[\/]/,
name: "renderer-skills-viewer",
chunks: "async",
priority: 12,
},
},
},
// Enable tree shaking
usedExports: true,
sideEffects: true,
}
: {},
output: {
// Use renderer-specific naming to avoid conflicts
chunkFilename: isProduction ? "renderer.[name].[contenthash].js" : "renderer.[name].js",
filename: isProduction ? "renderer.[name].[contenthash].js" : "renderer.[name].js",
},
// Performance optimizations
performance: {
hints: isProduction ? "warning" : false,
maxEntrypointSize: 1024000, // 1MB
maxAssetSize: 512000, // 512KB
},
};