Search code examples
node.jsexpressbrunchchaplinjs

How to setup environment variables in Brunch


We're developing an app using Chaplin on top of brunch.

We're consuming a 3rd party API and we have different tokens for development and production.

I was wondering if it's possible to setup env variables in Brunch. I'd like to compile everything to plain html/js.

Is there a way to compile the project using something like brunch build -env staging? If so, how can I define such variables?


Solution

  • https://github.com/brunch/brunch/issues/332

    1) using brunch cmd --environment ...

    2) using BRUNCH_ENV=development brunch cmd + process.env.BRUNCH_ENV