feat: addWebpackExternals

This commit is contained in:
Kyle Fang
2019-04-21 21:40:52 +08:00
parent f8e1501835
commit 698641326e
2 changed files with 15 additions and 0 deletions

View File

@@ -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,

View File

@@ -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: