How to use a library from a CDN in a Webpack project in production

In your webpack config you can use the externals option which will import the module from the environment instead of trying to resolve it normally:

// webpack.config.js
module.exports = {
  externals: {
    'react': 'React'
  }
  ...
};

Read more here:
https://webpack.js.org/configuration/externals/

Leave a Comment