Skip to content
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

Variables in index.html is not injected properly (or injected after HtmlWebpackPlugin optimizations) #6689

Closed
olessavluk opened this issue Mar 20, 2019 · 2 comments

Comments

@olessavluk
Copy link

Is this a bug report?

Yes

Did you try recovering your dependencies?

1.13.0

Which terms did you search for in User Guide?

Referencing Environment Variables in the HTML

Environment

Environment Info:

  System:
    OS: macOS 10.14.3
    CPU: x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
  Binaries:
    Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
    Yarn: 1.13.0 - ~/.nvm/versions/node/v10.15.3/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.15.3/bin/npm
  Browsers:
    Chrome: 72.0.3626.121
    Firefox: 64.0
    Safari: 12.0.3
  npmPackages:
    react: Not Found
    react-dom: Not Found
    react-scripts: Not Found
  npmGlobalPackages:
    create-react-app: 2.1.8

Steps to Reproduce

  1. Add the following to index.html file:
<meta name="NODE_ENV" content="%NODE_ENV%" />
<% if ("%NODE_ENV%" === "production") { %>
<script>
  console.log('it works!');
</script>
<% } %>
  1. yarn build

Expected Behavior

%NODE_ENV% will be injected properly:

<meta name="NODE_ENV" content="production" />
<script>
  console.log('it works!');
</script>

Actual Behavior

Script tag is missing:

<meta name="NODE_ENV" content="production" />
@olessavluk
Copy link
Author

This may be a duplicate of #6448

@heyimalex
Copy link
Contributor

Yeah, it looks like a duplicate! I labeled it as a bug so it won't get stale, and I'm going to close this one. Thank you for looking through the tracker!

@lock lock bot locked and limited conversation to collaborators Mar 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants