Use environment variables in index.html

See original GitHub issue

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ x ] feature request

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
alan-agius4commented, May 26, 2020

Sounds to me that what you want is runtime configuration which in that case probably this is the same as https://github.com/angular/angular-cli/issues/7506 and partially related to https://github.com/angular/angular-cli/issues/3855

1reaction
bravikcommented, Mar 11, 2018

How about setting a html language tag html lang="xx" dynamicly basing on some variable… Cause you have to build angular app as many times as a number of locales you support…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create React App: using environment variables in index.html
I use .env variables for the meta title of a site with various language versions of the build: <title>%REACT_APP_SITE_TITLE%</title>.
Read more >
[Tips] How to Access Environment Variables Stored in .env ...
My current project required to embed Google Analytics tags in React project's index.html for two different environments, ...
Read more >
Replace Environment Variables In Your Index.html - Medium
We want to replace variables after the build as completed. To hook on a corresponding lifecycle we are using npm-scripts most precisely we...
Read more >
Accessing env variables from index.html · Issue #3105 - GitHub
Describe the bug I try to insert html tag by environment variable condition and use vite-plugin-html for it. But Vite behaviour is weird ......
Read more >
Using environment variables in Angular applications - Nx
While you cannot use variable in index.html , one workaround for this is to create different index.*.html files, such as index.prod.html , then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found