how to remove React-Devtools from production ?
Add following script to your main.html’s head section:
<script>
window.__REACT_DEVTOOLS_GLOBAL_HOOK__&&
(window.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject=function(){})
</script>
1 Like
I use
if (Meteor.absoluteUrl() === 'https://www.your_url.com' && typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'object') {
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject = () => {}
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.emit = () => {}
for (const [key, value] of Object.entries(window.__REACT_DEVTOOLS_GLOBAL_HOOK__)) {
if (typeof value === 'object') {
window.__REACT_DEVTOOLS_GLOBAL_HOOK__[key] = {}
}
}
}
1 Like
You can use it in Meteor.startup (imports/ui/index.js) on the client side right before you do
ReactDOM.render(
or any other rendering or hydration.
2 Likes
Doesn’t NODE_ENV=production work when you do meteor build?