reactjs 的生产 webpack 构建 - 看起来你正在使用 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 文件在 "production" 环境中构建应用程序。 它很简单,但是 "react development tools" 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" e "dependencies" 部分

"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.