0👍
In case anybody comes across the same issue I was able to figure it out.
I was using node-polyfill
and I am not 100% what it did but it stopped Terser from removing console.
Original (Broken version)
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
module.exports = function (api) {
build: {
chainWebpack(chain) {
chain.optimization.minimizer('js').tap((args) => {
args[0].terserOptions.compress.drop_console = true
args[0].terserOptions.compress.drop_debugger = true
return args
})
chain.plugin('node-polyfill').use(new NodePolyfillPlugin())
}
}
}
Working version
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
module.exports = function (api) {
build: {
chainWebpack(chain) {
chain.optimization.minimizer('js').tap((args) => {
args[0].terserOptions.compress.drop_console = true
args[0].terserOptions.compress.drop_debugger = true
return args
})
chain.plugin('node-polyfill').use(
new NodePolyfillPlugin({
excludeAliases: ['console'],
}),
)
}
}
}
Source:stackexchange.com