Bud.env usage

From docs everything looks easy.

I need to add to .env any key/value which starts from PUBLIC_. For example, PUBLIC_TEST.

than yarn build and variable should be able at window, but I can’t see any PUBLIC_TEST, TEST, test or public_test.

I even have tried to add PUBLIC_TEST as a global variable to wp-config.php but without a result.

Any thoughts?

The docs are a bit out of date, sorry.

  1. These values are not attached to window.
  2. You don’t include PUBLIC_ when referencing them in app code.

When I was testing, I also realized that these values should be run through json.stringify, otherwise you have to bake quotes into the env file.

Accomplished updating the docs and stringifying values in ✨Improve(patch): stringify env values by kellymears · Pull Request #1604 · roots/bud · GitHub.

For now, I tested with 6.3.3 and by setting:

// .env
// src/app.js 

All seems to output as expected:

// dist/js/app.js
// ....
    813: () => {
// ...
1 Like

Thank you!
Works for me!