hughsk / envify

:wrench: Selectively replace Node-style environment variables with plain strings.
901 stars 57 forks source link

doesn't seem to work with symlinked files #17

Closed davidchase closed 9 years ago

davidchase commented 9 years ago

So i have some files symlinked into node_modules more on it here.

That way i can require('myServices/service'); instead of require('../../../myServices/service')

Unfortunately if i have something like process.env.MY_VAR inside that file (service.js) it will not be transformed.

Any thoughts or suggestions?

davidchase commented 9 years ago

Nevermind it seems that if you have services symlinked or living in node_modules you just have to include another package.json in that folder as well as use the browserify.transform field ie:

"browserify": {
        "transform": ["envify"]
    }
m90 commented 9 years ago

@davidchase Did you ever get this running using command line browserify? Your solution works fine for me when using browserify-middleware but will fail just like before when I try to build a file from the command line:

$ browserify ./public/js/main.js -t jadeify -t envify > ./dist/some-module.js 
m90 commented 9 years ago

Forget about it, I just needed to use -g instead of -t:

$ browserify ./public/js/main.js -g jadeify -g [ envify --NODE_ENV production ] > ./dist/some-module.js