Actually, you have been right all along - i.e. you needed
NODE_ENV=production
because your configuration files depend on that environment variable to select your production configuration.--define process.env.NODE_ENV='production'
“defines a free variable”
WTH???
Lets say you have this in your front end code:
if(process.env.NODE_ENV !== 'production') {
console.log('Not Production');
}
and in your package.json
scripts:
"build": "webpack --define process.env.NODE_ENV=\"'production'\"",
the define
causes webpack to replace process.env.NODE_ENV
with 'production'
, i.e.
if('production' !== 'production') {
console.log('Not Production');
}
which webpack promptly rewrites as
if(false) {
console.log('Not Production');
}
which uglify
will promptly strip out on the minimization pass.
This setting has caused no end of confusion since webpack 2.