Skip to content Skip to sidebar Skip to footer

Webpack To Build Without Including Peer Dependencies

I am building a React library and using Webpack to bundle it. I'm well aware of the concept behind dependencies and peer dependencies. In the project, React is specified as a peer

Solution 1:

I figured it out.

Webpack has a configuration called externals. Anything specified as an external will not be bundled together.

All I had to do was to add this config to webpack.config.babel.js

externals: {
  react: 'react',
  reactDOM: 'react-dom'
}

More info here - webpack externals

Post a Comment for "Webpack To Build Without Including Peer Dependencies"