Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concatenation not working #358

Open
apuatcfbd opened this issue Apr 6, 2023 · 4 comments · May be fixed by #253 or #342
Open

Concatenation not working #358

apuatcfbd opened this issue Apr 6, 2023 · 4 comments · May be fixed by #253 or #342
Assignees

Comments

@apuatcfbd
Copy link

REACT_APP_URL_PROTOCOL=https
REACT_APP_URL=site.com

REACT_APP_BASE_URL="${REACT_APP_URL_PROTOCOL}://${REACT_APP_URL}"

This format was working with CRA but this is not working with env-cmd,

used like "build:test": "env-cmd -f .env.production.test react-app-rewired build"

Is there any way to make this work? Concatenation is important for my case

@pjetrucha
Copy link

@apuatcfbd
As a workaround, put a variable with concatenation (REACT_APP_BASE_URL) in env files that are default for CRA, such as:
https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used

@apuatcfbd
Copy link
Author

Thanks @pjetrucha but I didn't get it. I've different env's for different stages. in that scenario how do I do that?
I need this (for same env's vars): https://create-react-app.dev/docs/adding-custom-environment-variables/#expanding-environment-variables-in-env

@pjetrucha
Copy link

The CRA with env-cmd merges all the files together, so in your example, it will search for:

.env.production.test, .env.production.local, .env.local, .env.production, .env

The first file is from env-cmd, so variable expansion doesn't work in it, but you can move it to one of 4 other files that CRA will look for, e.g.:

# .env.production.test
REACT_APP_URL_PROTOCOL=https
REACT_APP_URL=site.com

# .env
REACT_APP_BASE_URL="${REACT_APP_URL_PROTOCOL}://${REACT_APP_URL}"

@toddbluhm
Copy link
Owner

Yeah, this needs to be looked into/fixed...possibly by one of the PRs attached

@apuatcfbd is what you have listed in your post the exact reproduction case, or is there additional data needed? In other words, what is the simplest use case so that I can recreate a test case for it?

@toddbluhm toddbluhm self-assigned this Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants