You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
You run REACT_APP_STAGE=... but refer as NODE_ENV which is not correct.
@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...
Webpack DefinePlugin replaces occurence with a quoted value (e.g. if you write process.env.NODE_ENV === 'production', you get "production" === 'production').
One may expect InterpolatePlugin behaving in the same matter, but apparently not. Both code and docs (docs are not mentioning that InterpolatePlugin behaves differently compare to DefinePlugin) need to be updated.
The PR I linked to handles it. The issue is in the order the plugins run: minification is happening before interpolation, so '%NODE_ENV%' === 'production' is removed before%NODE_ENV% is replaced with production.
Activity
heyimalex commentedon Jul 29, 2019
I think this is being handled in #6449
miraage commentedon Jul 30, 2019
You run
REACT_APP_STAGE=...but refer asNODE_ENVwhich is not correct.salomvary commentedon Jul 30, 2019
@miraage Well, it's technically correct but irrelevant for the reproduction example. Updated the description and removed it to avoid further confusion.
miraage commentedon Jul 30, 2019
@salomvary I have completely missed the point you're raising. This is very interesting...
Webpack DefinePlugin replaces occurence with a quoted value (e.g. if you write
process.env.NODE_ENV === 'production', you get"production" === 'production').One may expect InterpolatePlugin behaving in the same matter, but apparently not. Both code and docs (docs are not mentioning that InterpolatePlugin behaves differently compare to DefinePlugin) need to be updated.
heyimalex commentedon Aug 5, 2019
The PR I linked to handles it. The issue is in the order the plugins run: minification is happening before interpolation, so
'%NODE_ENV%' === 'production'is removed before%NODE_ENV%is replaced withproduction.