NX Dev Not Replacing an Environment Variable in a React Project


We are using nx.dev to build a set of apps and libraries for one of our clients.

Recently we found out that a CI/CD script we use to set the version number in the index.html file of the react apps was not working.

It simply appends a GET parameter to a static file that we’re loading – both to prevent cache and to know which build of the app we are currently running.

This is something we have in all our projects, but they are all using CRA (or CRACAO).

The issue with NX, turned out to be that environment variables are only replaced if they start with NX. E.g. %ENV_VAR% is not going to be replaced with the value of the environment variable, but %NX_ENV_VAR% is going to work just fine.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.