Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !7029

Interpolate variables into template before minification

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/cedrics/interpolate-template-before-minification into master May 10, 2019
  • Overview 6
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: cedrics

Fixes https://github.com/facebook/create-react-app/issues/6448

We ran into a problem where a code snippet in our index.html was removed regardless of the NODE_ENV set:

 <script>
 if ("%NODE_ENV%" === "production") {
  // Production only configuration
}
 </script>

The problem was that the interpolation was only registered after the minification already ran. So from the minifier's point of view "%NODE_ENV%" === "production" is always false and the code block can therefore be eliminated.

I tested this out by using a local copy of react-scripts & react-dev-tools and rebuilding our project. I think the only potential bug this change could introduce would be if any steps between the template generation and the emit would actually themselves generate interpolated variables. Those would not be converted by the PR as it is. It may be possible to run the interpolation for both hooks if this turns out to be a problem.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/cedrics/interpolate-template-before-minification