Open gowravshekar opened 9 years ago
This is why always using braces around your if clauses is good coding practice.
I caught this error when using some library code. I ended up using UglifyJsPlugin to accomplish the same.
new webpack.optimize.UglifyJsPlugin({
compress: {
drop_console: true
}
})
This works with the above code.
This sucks but the only real way to do this is to convert code to an AST, strip function calls, then back to code. Which is what I was attempting to do with recast, but I just haven't had time for it.
If anyone else would like to help with that, I'd welcome it.
I've actually written code to do this as a Grunt task in my DoppioJVM project, but it doesn't work for functions invoked on an object (e.g. works for log(), but not console.log()). It's MIT licensed, so feel free to use it as a starting point.
Using the configuration
For the below code snippet in the file, leads to error.
Error
Unexpected token else You may need an appropriate loader to handle this file type.