我已经创建了一个基本的应用程序并将其部署到生产环境中。运行 webpack -p 并启动服务器后,我现在收到此控制台日志错误:
You are currently using minified code outside of NODE_ENV === 'production'. This means that you are running a slower development build of Redux. You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) to ensure you have the correct code for your production build.
这是我的 webpack.config.js 文件:
module.exports = {
entry: [
'./src/index.js'
],
output: {
path: __dirname,
publicPath: '/',
filename: 'bundle.js'
},
module: {
loaders: [{
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['react', 'es2015', 'stage-1']
}
}]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
devServer: {
historyApiFallback: true,
contentBase: './'
}
};
我对 React 和 Webpack 尤其陌生。如果有人可以指出出了什么问题并帮助我了解 webpack(这非常令人困惑),那么我将永远感激不尽!
编辑:
我添加了 webpack 插件并运行NODE_ENV=production webpack -p
并在终端中出现此错误:
/Users/Joseph/workspace/weather-fcc/webpack.config.js:27
new webpack.DefinePlugin({
^
ReferenceError: webpack is not defined
at Object.<anonymous> (/Users/Joseph/workspace/weather-fcc/webpack.config.js:27:9)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at requireConfig (/usr/local/lib/node_modules/webpack/bin/convert-argv.js:96:18)
at /usr/local/lib/node_modules/webpack/bin/convert-argv.js:109:17` FWIW my webpack version is 1.12.9