Javascript Package - Dependency in WebPack
To exclude a package with webpack, you have to:
In development mode, it allows to avoid bundling all dependencies, which allows browsers to cache those libraries between builds.
Example with JQuery that is available on the global variable 'jQuery'. The below configuration tells WebPack to map the import (for instance for a commonjs module - require(“jquery”)) to the global variable jQuery
externals: {
// JQuery is a peer dependency (external) and available globally with the jQuery variable
jquery: "jQuery"
}
Other examples:
externals: [
"react": "React",
"react-dom": "ReactDOM"
'library/one',
'library/two',
// Everything that starts with "library/"
/^library\/.+$/
]