I'm using Reactjs on an app and it's time to build it for production. As I show below, my package.json has the pack:prod command that uses webpack and a specific webpack.config.js file to build the app on "production" environment. It simply works but the "react development tools" chrome plugin keep saying I'm using a minified development version instead of the production version.
Does any one knows what else can I do to get it working on my env? I got the same command and webpack files from another project that doesn't show this error on prod builds.
my webpack config files and package.json below:
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" e "dependencies" section
"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"
}
The message I keep seeing on browser's console is
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.
The Error lies in the command you are running. ie
"pack:prod": "webpack -p --progress --cofig webpack.prod.config.js"
It should be --config
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.