question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditional content in index.html

See original GitHub issue

Hello! It is possible in index.html to include some content based on NODE_ENV ? For example when I am in production I want to include Google Analytics, or other services scripts. Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
iamandrewlucacommented, Sep 12, 2017

@gaearon LOL, it works, great! Thanks! added this in head tag

<% if (process.env.NODE_ENV === 'production') { %>
  <script>
    // my GA script
  </script>
<% } %>
2reactions
gaearoncommented, Sep 12, 2017

I think we might accidentally support ejs there although it wasn’t really intentional 😛 Let me know if you can make it work somehow.

In general though I find it might be easier to set this up from JS by appending script tags.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Conditionally Change index.html in React
Let's see how to make your index.html content depends on environment variables by using HtmlWebpackPlugin, which is included in Create React ...
Read more >
How to add condition in index.html file in react js
I want to use the google tag manager script just for the signup page. I don't want them for other pages. How can...
Read more >
How To Build HTML for Conditional Statements
This article will cover the use of conditional statements inside HTML blocks to control dynamic content in your emails.
Read more >
Conditionally include a meta tag in index.html of a create-react ...
I have a tag I want in the staging version of my app. <meta name="robots" content="noindex" />. But I don't want it in...
Read more >
Create React App, NPM Build, Add Conditional Content and ...
Create React App, NPM Build, Add Conditional Content and Production Scripts to Index.html. 12/20/2020 8:39:58 PM ...
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