-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
43 lines (42 loc) · 1.25 KB
/
webpack.config.js
File metadata and controls
43 lines (42 loc) · 1.25 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
const path = require("path");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
module.exports = {
entry: "./src/index.js",
output: {
filename: "[name].bundle.js",
path: path.resolve(__dirname, "dist"),
},
optimization: {
splitChunks: {
chunks: "all",
maxInitialRequests: Infinity, // Increases the number of parallel requests at entry
minSize: 0, // Minimum chunk size in bytes
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
// Grabs the folder name of the package
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
// Avoids vendor prefix and better naming for chunks
return `npm.${packageName.replace("@", "")}`;
},
chunks: "all",
},
},
},
},
plugins: [
new BundleAnalyzerPlugin(), // Helps to visualize size of webpack output files with an interactive zoomable treemap.
],
module: {
rules: [
{
test: /\.jsx?$/, // Transpile .js and .jsx files
exclude: /node_modules/,
use: {
loader: "babel-loader", // Use babel-loader for these files
},
},
],
},
};