Created
August 3, 2021 21:21
-
-
Save philippegirard/01fd4e68795a89194035c2c21a9177b6 to your computer and use it in GitHub Desktop.
webpack5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { environment } = require('@rails/webpacker') | |
const { CleanWebpackPlugin } = require("clean-webpack-plugin"); | |
environment.plugins.prepend("CleanWebpackPlugin", new CleanWebpackPlugin()); | |
// default config from https://webpack.js.org/plugins/split-chunks-plugin/#optimizationsplitchunks | |
environment.splitChunks((config) => | |
Object.assign({}, config, { | |
optimization: { | |
splitChunks: { | |
chunks: "all", // changed to "all" from "async" in default | |
minSize: 20000, | |
// minRemainingSize: 0, // this option does not work with webpack even included in default | |
maxSize: 0, | |
minChunks: 1, | |
maxAsyncRequests: 30, | |
maxInitialRequests: 30, | |
automaticNameDelimiter: "~", | |
enforceSizeThreshold: 50000, | |
cacheGroups: { | |
defaultVendors: { | |
test: /[\\/]node_modules[\\/]/, | |
priority: -10, | |
}, | |
default: { | |
minChunks: 2, | |
priority: -20, | |
reuseExistingChunk: true, | |
}, | |
}, | |
}, | |
}, | |
}) | |
); | |
module.exports = environment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment