W
W
WarriorKodeK2018-05-24 11:52:57
React
WarriorKodeK, 2018-05-24 11:52:57

What does the error "React is running in production mode, but dead code elimination has not been applied" mean?

What might be causing this error?
On the local everything works, but when I send it to the build, then after a while the following error occurs on the build
5b067c0f9a7cb882939852.png
Webpack prod -

const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
  entry: [
    './dev/js/index'
  ],
  output: {
    path: path.join(__dirname, 'dist/js'),
    publicPath: "/js/",
    filename: 'bundle.js',
  },
  target: 'node',
  module: {
    loaders: [
      {
        test: /\.(js|jsx)$/,
        include: path.join(__dirname, 'dev/js'),
        exclude: /node_modules/,
        loader: "babel-loader",
        options: {
          presets: [ 'react', 'es2015', 'stage-0']
        }
      },
      {
        test: /\.(sass|scss)/,
        include: path.join(__dirname, 'dev/sass'),
        loader: 'style-loader!css-loader!sass-loader'
      },
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader'
      },
      {
        test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
        loaders: ['url-loader']
      },
      {
        test: /\.(png|jpg)$/,
        loader: 'url-loader'
      }
    ]
  },

  plugins: [
    new webpack.optimize.OccurrenceOrderPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('production')
      }
    }),
    new UglifyJSPlugin({
      "mangle": {
        "screw_ie8": true
      },
      "compress": {
        "screw_ie8": true,
        "warnings": false
      },
      "sourceMap": false
    })
  ],
};

Webpack prod-dev
const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
  entry: [
    './dev/js/index'
  ],
  output: {
    path: path.join(__dirname, 'dist/js'),
    publicPath: "/js/",
    filename: 'bundle.js',
  },
  target: 'node',
  module: {
    loaders: [
      {
        test: /\.(js|jsx)$/,
        include: path.join(__dirname, 'dev/js'),
        exclude: /node_modules/,
        loader: "babel-loader",
        options: {
          presets: [ 'react', 'es2015', 'stage-0']
        }
      },
      {
        test: /\.(sass|scss)/,
        include: path.join(__dirname, 'dev/sass'),
        loader: 'style-loader!css-loader!sass-loader'
      },
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader'
      },
      {
        test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
        loaders: ['url-loader']
      },
      {
        test: /\.(png|jpg)$/,
        loader: 'url-loader'
      }
    ]
  },

  plugins: [
    new webpack.optimize.OccurrenceOrderPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('production'),
        'NODE_CUSTOM_MODE': JSON.stringify('development'),
      }
    }),
    new UglifyJSPlugin({
      "mangle": {
        "screw_ie8": true
      },
      "compress": {
        "screw_ie8": true,
        "warnings": false
      },
      "sourceMap": false
    })
  ],
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-05-24
@WarriorKodeK

At the end of the text of the error is a link with the answer to your question.
Read more: Tyts , tyts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question