我正在使用browserify v16.3.2来构建react v16应用。在创建的bundle.js
中,我发现既有react.development也有react.production.min,还有react-dom
我想将NODE_ENV设置为React official doc,但没有效果。
然后我尝试使用以下命令,它仍然包含所有react.development,react.production.min,react-dom.development和react-dom.production.min
NODE_ENV=production browserify -t [ babelify --ignore [ node_modules ] --compact --presets [ @babel/react @babel/env ] --plugins [ @babel/plugin-proposal-class-properties ] ] main.js -o bundle.js
这是我的main.js
import React from 'react';
import ReactDOM from 'react-dom';
class Example extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<p>Hello World</p>
);
}
}
ReactDOM.render(
<Example />,
document.getElementById('root')
);
预期:
是否包含react.development或react.production.min,取决于NODE_ENV。对于react-dom一样
实际:
所有的react.development,react.production.min,react-dom.development和react-dom.production.min都在