mirror of
https://github.com/zhigang1992/customize-cra.git
synced 2026-04-29 09:55:45 +08:00
feat: addWebpackExternals
This commit is contained in:
11
index.js
11
index.js
@@ -275,6 +275,16 @@ const disableChunk = () => config => {
|
||||
return config;
|
||||
};
|
||||
|
||||
// to be used to ignore replace packages with global variable
|
||||
// Useful when trying to offload libs to CDN
|
||||
const addWebpackExternals = (externalDeps) => config => {
|
||||
config.externals = {
|
||||
...config.externals,
|
||||
externalDeps
|
||||
};
|
||||
return config;
|
||||
};
|
||||
|
||||
const addPostcssPlugins = (plugins) => config => {
|
||||
const rules = config.module.rules.find(rule => Array.isArray(rule.oneOf))
|
||||
.oneOf;
|
||||
@@ -316,6 +326,7 @@ module.exports = {
|
||||
addBundleVisualizer,
|
||||
addBabelPlugin,
|
||||
addDecoratorsLegacy,
|
||||
addWebpackExternals,
|
||||
disableEsLint,
|
||||
addWebpackAlias,
|
||||
addWebpackResolve,
|
||||
|
||||
@@ -150,6 +150,10 @@ Adds the provided alias info into webpack's alias section. Pass an object litera
|
||||
|
||||
Adds the provided resolve info into webpack's resolve section. Pass an object literal with as many entries as you'd like, and the whole object will be merged in.
|
||||
|
||||
### addWebpackExternals(deps)
|
||||
|
||||
Add external dependencies, useful when trying to offload libs to CDN
|
||||
|
||||
### addBundleVisualizer(options, behindFlag = false)
|
||||
|
||||
Adds the bundle visualizer plugin to your webpack config. Be sure to have `webpack-bundle-analyzer` installed. By default, the options passed to the plugin will be:
|
||||
|
||||
Reference in New Issue
Block a user