-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added shared bundles configuration
- Loading branch information
hayes
committed
Mar 25, 2021
1 parent
0810d9d
commit 7c0a23b
Showing
5 changed files
with
67 additions
and
33 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
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,28 @@ | ||
const getChunkName = require('../../utilities/get-chunk-name'); | ||
const PackerConfig = require('../../config'); | ||
const config = new PackerConfig(require('../../../packer.schema')); | ||
|
||
const optimization = { | ||
nodeEnv: 'production', | ||
minimize: true, | ||
splitChunks: { | ||
cacheGroups: { | ||
defaultVendors: false, | ||
vendor: { | ||
test: /[\\/]node_modules[\\/]/, | ||
name: getChunkName, | ||
chunks: 'initial', | ||
priority: 5, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
if (config.get('build.sharedBundles')) { | ||
optimization.splitChunks.cacheGroups.default = { | ||
name: getChunkName, | ||
chunks: 'all', | ||
}; | ||
} | ||
|
||
module.exports = optimization; |