I spent today digging through our webpack 4 config trying to work out why a production bundle contained code like this:
if("production"!==e.env.NODE_ENV){//...
My expectation was that with webpack 4 and 'mode': 'production'
this meant that behind the scenes all process.env.NODE_ENV
statements should be converted to 'production'
. Subsequently Uglify would automatically get its groove on with the resulting if("production"!=="production") ...
and et voilà!... Strip the dead code.
It seemed that was not the case. I was seeing (regrettably) undead code. And who here actually likes the undead?