Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
fix: chunks on local (#7102)
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-deriv authored Feb 20, 2024
1 parent d4f9891 commit 57563b2
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,30 +420,32 @@ exports.onCreateWebpackConfig = ({ stage, actions, loaders, getConfig }, { ...op
const config = getConfig()
const isProduction = config.mode === 'production'

const splitChunks = {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
priority: -10,
},
bundle: {
test: /\.(js|ts|tsx)$/,
name: 'bundle',
chunks: 'all',
priority: -20,
enforce: true,
},
},
}

actions.setWebpackConfig({
devtool: isProduction ? false : 'inline-source-map', // enable/disable source-maps
mode: isProduction ? 'production' : 'development',
optimization: {
minimize: isProduction,
minimizer: [new TerserPlugin()],
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
priority: -10,
},
bundle: {
test: /\.(js|ts|tsx)$/,
name: 'bundle',
chunks: 'all',
priority: -20,
enforce: true,
},
},
},
...(isProduction && { splitChunks }),
mangleExports: 'size',
mangleWasmImports: true,

Expand All @@ -462,9 +464,7 @@ exports.onCreateWebpackConfig = ({ stage, actions, loaders, getConfig }, { ...op
providedExports: true,
usedExports: true,
},
plugins: [
new StylelintPlugin({ ...style_lint_options, ...options }),
],
plugins: [new StylelintPlugin({ ...style_lint_options, ...options })],
resolve: {
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
},
Expand Down

0 comments on commit 57563b2

Please sign in to comment.