Skip to content

Commit

Permalink
[fixed] Updates webpack distribution config to reference the correct …
Browse files Browse the repository at this point in the history
…externals (reactjs#210)

Currently, if not using any kind of module loader, webpack falls back to looking for dependencies on the root (e.g. `window` in the browser). React and ReactDOM both have different names when looking up on the root, and these different names can be specified by making the `externals` prop an object where the values represent an object of loader type => name.

See [react-redux's webpack config](https://github.com/reactjs/react-redux/blob/master/webpack.config.js) for an example.
  • Loading branch information
icdevin authored and claydiffrient committed Aug 10, 2016
1 parent f0933fd commit d347547
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions webpack.dist.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,30 @@ var webpack = require('webpack');
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
var env = process.env.WEBPACK_ENV;

var reactExternal = {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
};
var reactDOMExternal = {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
};

module.exports = {

entry: {
'react-modal': './lib/index.js',
'react-modal.min': './lib/index.js'
},

externals: [
'react',
'react-dom'
],
externals: {
'react': reactExternal,
'react-dom': reactDOMExternal
},

output: {
filename: '[name].js',
Expand Down

0 comments on commit d347547

Please sign in to comment.