Create-react-app: Way to add dynamic env field which change for every build creation. e.g timestamp

Created on 28 Oct 2018  路  3Comments  路  Source: facebook/create-react-app

Is this a bug report?

(write your answer here)
Way to add dynamic env field which change every build creation. e.g timestamp
No

Did you try recovering your dependencies?

yes

(Write your answer here.)

Which terms did you search for in User Guide?

dynamic env configs

(Write your answer here if relevant.)

Environment

mac os Mojave 10.14

(paste the output of the command here)

Steps to Reproduce

(Write your steps here:)

  1. Added .env file
    2.Added REACT_APP_DATE_TIME = new Date().toDateString() in .env file// I know it will not work
  2. In index.js file I added
    import dotenv from "dotenv"
    dotenv.config()

Expected Behavior

(Write what you thought would happen.)
I want to add date time of build, in one of my component (Footer component)
How can i do that , I was able to do it when ejected out. But not while I was non ejected
May be I am ignorant here, Please suggest if its possible without ejecting ?

Actual Behavior

(Write what happened. Please add screenshots!)

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Most helpful comment

Answered on SO thread.

All 3 comments

Answered on SO thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rovansteen picture rovansteen  路  192Comments

gaearon picture gaearon  路  86Comments

riceyeh picture riceyeh  路  116Comments

daviseford picture daviseford  路  108Comments

benneq picture benneq  路  99Comments