美好的一天!我在生产上有一些麻烦:需求没有定义.它由react.production.min.js引起.这是我的webpack.config.js && package.json
webpack.config.js
const path = require('path');
const webpack = require('webpack');
const debug = process.env.NODE_ENV !== 'production';
let plugins = [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.ProvidePlugin({
Promise: 'imports-loader?this=>global!exports-loader?global.Promise!core-js/es6/promise',
fetch: 'imports-loader?this=>global!exports-loader?global.fetch!fetch-polyfill'
}),
new webpack.DefinePlugin({
'process.env':{
'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'BASE_URL':JSON.stringify(process.env.BASE_URL)
}
})
];
if(!debug) {
plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
unsafe_comps: true,
properties: true,
keep_fargs: false,
pure_getters: true,
collapse_vars: true,
unsafe: true,
warnings: false,
screw_ie8: true,
sequences: true,
dead_code: true,
drop_debugger: true,
comparisons: true,
conditionals: true,
evaluate: true,
booleans: true,
loops: true,
unused: true, …Run Code Online (Sandbox Code Playgroud)