hughsk / envify

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

Using envify in laravel/elixir project #40

Closed ghost closed 8 years ago

ghost commented 8 years ago

I have this in my gulpfile.js

elixir(function(mix) {
   mix.browserify(['app.jsx'], 'public/js/app.js');
});

How can I add envify so I could use env variables in my app.jsx ? Thanks

yoshuawuyts commented 8 years ago

From the docs using transforms can be done by adding a transform field:

var elixir = require('laravel-elixir');
var browserify = require('laravel-elixir-browserify');

elixir(function(mix) {
    browserify.init();

    mix.browserify("bootstrap.js", {
        transform: ["envify/custom"],
    });
});

Cheers!