forked from FinesseStudioLab/Trivela
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
45 lines (44 loc) · 1.16 KB
/
Copy pathwebpack.config.js
File metadata and controls
45 lines (44 loc) · 1.16 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
const path = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
entry: './src/index.tsx',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[contenthash].js',
chunkFilename: '[name].[contenthash].chunk.js',
},
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
// Vendor chunks (node_modules)
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
priority: 10,
},
// Heavy libraries
stellar: {
test: /[\\/]node_modules[\\/]@stellar[\\/]/,
name: 'stellar-sdk',
priority: 20,
},
react: {
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
name: 'react-vendor',
priority: 20,
},
},
},
},
performance: {
// Bundle size budget
maxEntrypointSize: 400000, // 400 KB
maxAssetSize: 300000, // 300 KB
hints: 'error', // Fail build if exceeded
},
plugins: [
// Analyze bundle composition
process.env.ANALYZE && new BundleAnalyzerPlugin(),
].filter(Boolean),
};