-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Environment variable evaluation not working in index.html #5473
Comments
I can't give a satisfying reason as to why this is happening, but I can give a fix. <script>
'%REACT_APP_ENV%'.toString() === 'production' ? console.log('production') : console.log('not production')
</script> I'm not sure why we would have to add |
Maybe they are not at build time, when the condition is evaluated. Thanks for the temporary fix though! |
+1 Have the same issue.
got => It looks like the environements variables have differents values / are not set inside a build tool (probably webpack). Adding ".toString()" probably delay the evaluation of the expression at runtime Note: I'm using "react-scripts": "2.1.1", |
* Fixed based on this ticket: facebook/create-react-app#5473
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue. |
|
Is this a bug report?
yes
Did you try recovering your dependencies?
yes
Environment
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Binaries:
Node: 10.9.0 - /usr/local/bin/node
npm: 6.2.0 - /usr/local/bin/npm
Browsers:
Chrome: 70.0.3538.67
Safari: 12.0
npmPackages:
react: ^16.5.2 => 16.5.2
react-dom: ^16.5.2 => 16.5.2
react-scripts: ^2.0.3 => 2.0.5
npmGlobalPackages:
create-react-app: Not Found
Steps to Reproduce
public/index.html
file based on an env variable:REACT_APP_ENV=production react-scripts build
build/index.html
Expected Behavior
You should see
<script>console.log('production')</script>
Actual Behavior
you see:
<script>console.log('not production')</script>
The text was updated successfully, but these errors were encountered: