![](/img/trans.png)
[英]It looks like you're using a minified copy of the development build of React
[英]Production webpack build of reactjs - It looks like you're using a minified copy of the development build of React
我在應用程序上使用Reactjs,現在該為生產構建它了。 如下所示,我的package.json具有pack:prod命令,該命令使用webpack和特定的webpack.config.js文件在“生產”環境中構建應用程序。 它只是可以工作,但是“反應開發工具” chrome插件一直在說我使用的是縮小版的開發版本,而不是正式版。
有誰知道我還能做些什么才能使其在我的環境中正常工作? 我從另一個項目中獲得了相同的命令和webpack文件,但在prod構建中未顯示此錯誤。
我的webpack配置文件和package.json如下:
webpack.config.js
module.exports = {
entry: ['./src/App.js.jsx'],
output: {
path: '../static',
filename: 'index.bundled.js',
publicPath: '/static/'
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.scss$/,
loaders: ["style-loader", "css-loader", "sass-loader"]
}
]
},
devServer: {
headers: { "Access-Control-Allow-Origin": "*" },
proxy: {
'/': {
target: 'http://localhost:8080',
changeOrigin: true
}
}
},
plugins: []
}
webpack.prod.config.js
let config = require('./webpack.config.js');
let webpack = require('webpack');
config.plugins = [
new webpack.DefinePlugin({
"process.env": {
"NODE_ENV": JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin()
]
module.exports = config;
package.json
“腳本”和“依賴項”部分
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"pack": "webpack --progress",
"pack:prod": "webpack -p --progress --cofig webpack.prod.config.js",
"dev-server": "webpack-dev-server --content-base static/ --port 9999 --hot --inline"
},
"author": "",
"license": "ISC",
"devDependencies": {
"axios": "^0.15.3",
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"classnames": "^2.2.5",
"css-loader": "^0.26.1",
"js-cookie": "^2.1.3",
"material-ui": "^0.17.1",
"moment": "^2.18.1",
"node-sass": "^4.3.0",
"qs": "^6.3.1",
"react": "^15.3.2",
"react-dom": "^15.4.2",
"react-maskedinput": "^3.3.4",
"react-router": "^3.0.2",
"react-tap-event-plugin": "^2.0.1",
"react-text-mask": "^3.0.0",
"sass-loader": "^4.1.1",
"style-loader": "^0.13.1",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2"
}
我一直在瀏覽器控制台上看到的消息是
index.bundled.js:2 Warning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See https: // fb.me/react-minification for more details.
錯誤在於您正在運行的命令。 即
"pack:prod": "webpack -p --progress --cofig webpack.prod.config.js"
它應該是--config
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.