-
Notifications
You must be signed in to change notification settings - Fork 31
How to simulate 'if debug' without changing source code (using gulp&webpack) #16
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
Comments
@ron23 you could use // webpack.config.js
var webpack = require('webpack');
module.exports = {
// ...
plugins: [
new webpack.DefinePlugin({
__DEV__: JSON.stringify(process.env.NODE_ENV !== 'production')
})
],
}; In your source you'd have something like this... // index.js
var immutable = require('immutable');
if (__DEV__) {
var installDevTools = require('immutable-devtools');
installDevTools(immutable);
} When you set
generates var immutable = require('immutable');
if (false) {
var installDevTools = require('immutable-devtools');
installDevTools(immutable);
}
// ... And then by adding the
var immutable = require('immutable');
// ... |
Nice! I thought about everything you said but I didn't know the magic -p !!! Thanks a lot! |
@ron23 you're welcome! You can also get dead code elimination by adding the uglifyjs plugin |
Already using it, just didn't know about the dead code removal feature. Thanks a bunch! |
Hi everybody! |
@ron23 Thanks! I've added section Using with webpack in Readme based on your comment |
Hi,
So i'm trying to use this GREAT tool but I don't want to change the source code, and I want it to work only in debug mode. I'm using gulp and webpack to build.
Any ideas, recommendations, examples?
Thanks!
The text was updated successfully, but these errors were encountered: