-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(mc-scripts): manually group some vendor chunks
- Loading branch information
Showing
5 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@commercetools-frontend/mc-scripts': patch | ||
--- | ||
|
||
Manually group some vendor chunks |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Dependencies to be split/grouped into separate chunks. | ||
// This is useful to reduce the main bundle size and have more | ||
// dedicated caching strategy for specific chunks. | ||
// https://webpack.js.org/plugins/split-chunks-plugin/ | ||
// https://rollupjs.org/configuration-options/#output-manualchunks | ||
const manualChunks = { | ||
'apollo-client': ['@apollo/client'], | ||
'core-js-pure': ['core-js-pure'], | ||
'commercetools-uikit-icons': ['@commercetools-uikit/icons'], | ||
moment: ['moment', 'moment-timezone'], | ||
react: [ | ||
'react', | ||
'react-dom', | ||
'react-router', | ||
'react-router-dom', | ||
'react-intl', | ||
], | ||
redux: [ | ||
'@reduxjs/toolkit', | ||
'redux', | ||
'react-redux', | ||
'redux-logger', | ||
'redux-thunk', | ||
], | ||
'sentry-browser': ['@sentry/browser'], | ||
}; | ||
|
||
const webpackCacheGroups = Object.entries(manualChunks).reduce( | ||
(previousChunks, [chunkName, vendors]) => { | ||
return { | ||
...previousChunks, | ||
[chunkName]: { | ||
test: new RegExp(`[\\/]node_modules[\\/](${vendors.join('|')})[\\/]`), | ||
name: chunkName, | ||
chunks: 'all', | ||
}, | ||
}; | ||
}, | ||
{} | ||
); | ||
|
||
export { manualChunks, webpackCacheGroups }; |