Coder Social home page Coder Social logo

Concatenation not working about env-cmd HOT 3 OPEN

apuatcfbd avatar apuatcfbd commented on June 14, 2024 1
Concatenation not working

from env-cmd.

Comments (3)

pjetrucha avatar pjetrucha commented on June 14, 2024 1

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}"

from env-cmd.

pjetrucha avatar pjetrucha commented on June 14, 2024

@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

from env-cmd.

apuatcfbd avatar apuatcfbd commented on June 14, 2024

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

from env-cmd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.