New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
transform-remove-console
exclude options not working on React Native project
#950
Comments
Same problem with React Native 0.59.8 |
I am using React Native 0.60.5, and module.exports = {
"presets": ["module:metro-react-native-babel-preset"],
"env": {
production: {
plugins: ["react-native-paper/babel", "transform-remove-console"]
}
}
} |
I updated to react-native 0.61.2 and modified my module.exports = function(api) {
console.log("BABELCONFIG", api.version, api.env("production"), api.env(), process.env.NODE_ENV, process.env.BABEL_ENV);
return {
"presets": ["module:metro-react-native-babel-preset"],
"plugins": ["react-native-paper/babel", "transform-remove-console"]
}
} During build I get the following output:
using It appears as though |
For anyone that happens upon this, and has been affected by it, I've found that using the following as my module.exports = function(api) {
api.cache(true);
if (process.env.NODE_ENV === 'production' || process.env.BABEL_ENV === 'production') {
return {
"presets": ["module:metro-react-native-babel-preset"],
"plugins": ["react-native-paper/babel", ["transform-remove-console", {"exclude": ["error", "warn", "info"]}]]
}
} else {
return {
"presets": ["module:metro-react-native-babel-preset"],
}
}
} |
how to do this code in react js |
Thanks @echolocation your solution works for me in RN |
How are you specifying this value on the command line? |
For those using react-native and generating an artifact like an .ipa or a .apk, how do you affirm a before/after for seeing that console.log is not being included in builds that should be stripping it out? |
Describe the bug
I'm using the
exclude
options but it doesn't seem to have any effect as all logs are removed.To Reproduce
.babelrc
Actual Output
All
console.*
output is removed.Expected Output
console.warn
,console.info
andconsole.error
should still work.Configuration
How are you using babel-minify?
"metro-minify-uglify"
Additional context
React Native 0.54.4
The text was updated successfully, but these errors were encountered: