Skip to content

Commit

Permalink
build: common config to generate vendor chunks
Browse files Browse the repository at this point in the history
This config provides one place to make changes and to get reflected everywhere.
  • Loading branch information
nikhilnayyar002 committed Jul 22, 2021
1 parent bacd60c commit 01d56b6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ module.exports = {
]
]
}),
generateIntialVendorChunk: true,
generateAsyncVendorChunk: true,
asyncVendorChunkMinSize: 1024, // https://github.com/webpack/webpack/issues/13768
dev: {
clientIPAddresses: getClientIPAddresses(clientPort, devHttpsMode),
sourceMaps: false,
Expand All @@ -106,7 +109,6 @@ module.exports = {
},
prod: {
combineStyleSheets: false,
combineAllNodeModulesDeps: true
}
},
environmentVariablesInApp: [], // strings
Expand Down
10 changes: 5 additions & 5 deletions webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ const o3 = merge(o2, {
minimize: false,
runtimeChunk: 'single',
chunkIds: 'named',
// moduleIds: 'deterministic',
splitChunks: {
chunks: 'all',
cacheGroups: {
vendorInitial: {
vendorsInitial: wConfig.generateIntialVendorChunk ? {
test: /[\\/]node_modules[\\/]/,
chunks: 'initial',
},
vendorAsync: {
} : false,
vendorsAsync: wConfig.generateAsyncVendorChunk ? {
test: /[\\/]node_modules[\\/]/,
chunks: 'async',
},
minSize: wConfig.asyncVendorChunkMinSize
} : false,
},
},
}
Expand Down
10 changes: 5 additions & 5 deletions webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ const o2 = merge(o1, {
splitChunks: {
chunks: 'all',
cacheGroups: {
vendorsInitial: {
vendorsInitial: wConfig.generateIntialVendorChunk ? {
test: /[\\/]node_modules[\\/]/,
chunks: 'initial',
},
vendorsAsync: {
} : false,
vendorsAsync: wConfig.generateAsyncVendorChunk ? {
test: /[\\/]node_modules[\\/]/,
chunks: 'async',
minSize: 1024, // https://github.com/webpack/webpack/issues/13768
},
minSize: wConfig.asyncVendorChunkMinSize
} : false,
styles: wConfig.prod.combineStyleSheets ? {
name: "styles",
type: "css/mini-extract",
Expand Down

0 comments on commit 01d56b6

Please sign in to comment.