Skip to content

Instantly share code, notes, and snippets.

@philippegirard
Created August 3, 2021 21:18
Show Gist options
  • Save philippegirard/cb9750c21afcddc3f1eaf656ab8ae645 to your computer and use it in GitHub Desktop.
Save philippegirard/cb9750c21afcddc3f1eaf656ab8ae645 to your computer and use it in GitHub Desktop.
config/webpack/environment.js
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