-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Non-dead JavaScript is removed during build #7448
Comments
I think this is being handled in #6449 |
You run |
@miraage Well, it's technically correct but irrelevant for the reproduction example. Updated the description and removed it to avoid further confusion. |
@salomvary I have completely missed the point you're raising. This is very interesting... |
The PR I linked to handles it. The issue is in the order the plugins run: minification is happening before interpolation, so |
Describe the bug
react-scripts build
seems to be removing inline JavaScript code from index.html that should not be removed. It happens to code paths that are conditional and the condition contains a build-time '%VARIABLE%'.Workaround: move the build-time variable outside of the condition.
Did you try recovering your dependencies?
No, it's a newly created project.
Which terms did you search for in User Guide?
NODE_ENV, index.html, variables
Environment
Steps to reproduce
create-react-app
.public/index.html
and add a the snipped below after<body>
.npm run build
.build/index.html
Expected behavior
build/index.html
should contain the minified version of the entire snippet with%NODE_ENV%
replaced withproduction
.Actual behavior
This is what
build/index.html
contains instead (note that the first if block is entirely missing):Reproducible demo
https://github.com/salomvary/create-react-app-bug
The text was updated successfully, but these errors were encountered: