-
Notifications
You must be signed in to change notification settings - Fork 12k
Use environment variables in index.html #7704
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
Comments
I would also love to have this for configuring CSP meta-tag info depending on the environment, since angular does not work without 'unsafe-eval' in normal dev mode. |
How about setting a html language tag |
Hi @mackelito, do you invision this to be something during runtime or build time? |
We use such a feature in some of our projects where we have the ability to change the environment variables after the build. To do this, we have a declare namespace MyApp {
interface IEnvironmentConfiguration {
apiUrl: string;
// ...
}
}
/**
* NOTE: The global configuration variable should be consumed at runtime using:
* <code>
* import { ENVIRONMENT } from `~app/config`;
* </code>
*/
declare var MY_APP_ENVIRONMENT_CONFIGURATION: Readonly<MyApp.IEnvironmentConfiguration>; And then we provide a default // @ts-check
/** @type { Readonly<MyApp.IEnvironmentConfiguration> } */
window.MY_APP_ENVIRONMENT_CONFIGURATION = {
apiUrl: 'https://example.com/api/v1'
// ...
}; And we also have a script to generate a new <script src="environment/config.js"></script> And to avoid confusion, we renamed the old
|
lets keep tracking this in #3855 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Versions.
Repro steps.
The log given by the failure.
Desired functionality.
Have the possibility to use environment variables in the index.html file
Currently I have google analytics code in the environment files to be able to have different id´s.
This results in some warnings:
"A Parser-blocking, cross site (i.e. different eTLD+1) script, https://www.google-analytics.com/analytics.js, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message.See https://www.chromestatus.com/feature/5718547946799104 for more details."
Mention any other details that might be useful.
The text was updated successfully, but these errors were encountered: