Aessandro
Aessandro

Reputation: 5761

Webpack throws warning when running npm run build

I have the following:

var webpack = require('webpack');
var path = require('path');

var BUILD_DIR = path.resolve(__dirname, 'src/client/public');
var APP_DIR = path.resolve(__dirname, 'src/client/app');

var config = {
  entry: APP_DIR + '/index.jsx',
  output: {
    path: BUILD_DIR,
    filename: 'bundle.js'
  },
  module : {
    loaders : [
      {
        test : /\.jsx?/,
        include : APP_DIR,
        loader : 'babel'
      }
    ]
  }
};

module.exports = config;

when I run "npm run build" as for:

{
  "name": "whitbread",
  "version": "1.0.0",
  "description": "technical test",
  "main": "index.js",
  "scripts": {
    "dev": "webpack -d --watch",
    "build": "webpack -p"
  },
  "author": "Alessandro Santese",
  "license": "ISC",
  "dependencies": {
    "babel-core": "^6.17.0",
    "babel-loader": "^6.2.5",
    "babel-preset-es2015": "^6.16.0",
    "babel-preset-react": "^6.16.0",
    "react": "^15.3.2",
    "react-dom": "^15.3.2",
    "webpack": "^1.13.2"
  }
}

i get this warning message:

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.

How can I get rid of it?

Upvotes: 0

Views: 261

Answers (1)

uladzimir
uladzimir

Reputation: 5689

You need to prepare react for production, so try to add the following lines to your webpack config.

new webpack.DefinePlugin({
  "process.env": { 
    NODE_ENV: JSON.stringify("production") 
  }
})

Upvotes: 1

Related Questions