Skip to content

Commit d347547

Browse files
icdevinclaydiffrient
authored andcommitted
[fixed] Updates webpack distribution config to reference the correct externals (#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.
1 parent f0933fd commit d347547

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

webpack.dist.config.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,30 @@ var webpack = require('webpack');
22
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
33
var env = process.env.WEBPACK_ENV;
44

5+
var reactExternal = {
6+
root: 'React',
7+
commonjs2: 'react',
8+
commonjs: 'react',
9+
amd: 'react'
10+
};
11+
var reactDOMExternal = {
12+
root: 'ReactDOM',
13+
commonjs2: 'react-dom',
14+
commonjs: 'react-dom',
15+
amd: 'react-dom'
16+
};
17+
518
module.exports = {
619

720
entry: {
821
'react-modal': './lib/index.js',
922
'react-modal.min': './lib/index.js'
1023
},
1124

12-
externals: [
13-
'react',
14-
'react-dom'
15-
],
25+
externals: {
26+
'react': reactExternal,
27+
'react-dom': reactDOMExternal
28+
},
1629

1730
output: {
1831
filename: '[name].js',

0 commit comments

Comments
 (0)