Pete Pete - 1 year ago 125
React JSX Question

currently using minified code outside of NODE_ENV === 'production'. This means slower development build of Redux

So this is the full error:
You are currently using minified code outside of NODE_ENV === 'production'. This means that you are running a slower development build of Redux.

Right now I am using a 3rd party Charting library called CanvasJS which needs access to the Global scope. Additionally when I try and import it within any of my Modules it seems the actual code breaks when in the browser(probably a this problem). So my way to solve it was just to use web pack, then have gulp bundle the bundle.min.js with the minified Charting library.

This works just fine until I try a production build. Anyways my theory may be that the reference to CanvasJS may have gotten mangled in the process.

Here is my Webpack.config file:

var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');

module.exports = {
context: path.join(__dirname, "public"),
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/main.js",
resolve: {
alias: {
'react': 'react-lite',
'react-dom': 'react-lite'
module: {
loaders: [
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0'],
plugins: [ 'transform-class-properties', 'transform-decorators-legacy'],
output: {
path: __dirname + "/public/build/",
filename: "bundle2.min.js"
plugins: debug ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin(),
// new webpack.optimize.AggressiveMergingPlugin()
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),

I have tried to mark CanvasJS as External, but this did not work either, so I was wondering how can I get Redux to not "run slow", and have references to global objects?

thank you.

Answer Source

You need to add:

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

For your production config

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download