Created
August 3, 2021 21:18
-
-
Save philippegirard/cb9750c21afcddc3f1eaf656ab8ae645 to your computer and use it in GitHub Desktop.
config/webpack/environment.js
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 | |
minSize: 30000, | |
maxSize: 0, | |
minChunks: 1, | |
maxAsyncRequests: 30, // changed | |
maxInitialRequests: 30, // changed | |
automaticNameDelimiter: '~', | |
automaticNameMaxLength: 30, | |
name: true, | |
cacheGroups: { | |
vendors: { | |
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