mmiller42 / html-webpack-externals-plugin

Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.
MIT License
99 stars 16 forks source link

ReactDom is not defined #46

Open Dongd0825 opened 5 years ago

Dongd0825 commented 5 years ago

hello everyone, i have a question that i imort react and set externals, but also has error import React from 'react' import ReactDom from 'react-dom'

new HtmlWebpackExternalsPlugin({ externals: [{ module: 'react', entry: 'https://11.url.cn/now/lib/16.2.0/react.min.js', global: 'React', }, { module: 'react-dom', entry: 'https://11.url.cn/now/lib/16.2.0/react-dom.min.js', global: 'ReactDom', }], })

but also console error

external "ReactDom":1 Uncaught ReferenceError: ReactDom is not defined at Object. (external "ReactDom":1) at n (bootstrap:19) at Module. (index.js:89) at n (bootstrap:19) at bootstrap:83 at bootstrap:83

mmiller42 commented 5 years ago

Change global: 'ReactDom' to global: 'ReactDOM'. The compiled version of react-dom exports a global object called ReactDOM.

You can continue to import it as ReactDom.