Skip to content
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

/custom not working #55

Closed
electerious opened this issue Dec 26, 2016 · 2 comments
Closed

/custom not working #55

electerious opened this issue Dec 26, 2016 · 2 comments

Comments

@electerious
Copy link

electerious commented Dec 26, 2016

I've trouble getting the envify/custom version working. The following code bundles without errors, but still contains process.env.NODE_ENV. Nothing has been replaced:

const envify = require('envify/custom')

/* browserify() */.transform(envify({

	NODE_ENV: 'production'

}))/* .bundle() */

The normal module however works fine.

const envify = require('envify')

process.env.NODE_ENV = 'production'

/* browserify() */.transform(envify)/* .bundle() */

Is there a difference between setting process.env.NODE_ENV = 'production' and passing NODE_ENV: 'production' to the custom module?


Node v6.7.0
envify v4.0.0

All tests are passing on my setup.

@electerious
Copy link
Author

It's because this is missing in the documentation. It would have saved me some hours: #44

@kryten87
Copy link

kryten87 commented Apr 14, 2017

Just to make it perfectly clear what's going on here (and for the reference of anyone else who goes hunting for this in the future):

bundle.transform(envify({ NODE_ENV: 'production' }));

will "envify" your code but will not touch any packages imported from node_modules.

bundle.transform(envify({ NODE_ENV: 'production' }), { global: true });

will "envify" both your code and packages from node_modules.

Thanks to @electerious for finding this and @MohsenEkhtiari for submitting a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants