WebPack - Dependency




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"
  // Everything that starts with "library/"

See https://webpack.js.org/configuration/externals/

Powered by ComboStrap