I am trying to load a module conditionally and the condition seems to work however webpack still makes the conditional module part of the bundle when the condition is false, here is the import code:
if (process.env.FEAT_SUPPORT === 'on') {
require('feature');
console.log('Enabled')
} else {
console.log('disabled')
}
Even if the value is not 'on' it still requires the module. I tested this using the log lines and the correct log lines appear when it is on and off.
I am using the Webpack define plugin to set the variable. The main reason for doing the above is to keep the bundle size small and it doesn't seem to be doing it.
webpack.optimize.UglifyJsPlugin).