Skip to content

Commit

Permalink
RSC: Check if index.html has already been updated during setup (#9197)
Browse files Browse the repository at this point in the history
With this check in place it's now safe to run the setup command multiple
times, which is great when testing it.
  • Loading branch information
Tobbe committed Sep 18, 2023
1 parent e2c14eb commit 83d180f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/cli/src/commands/experimental/setupRscHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ export const handler = async ({ force, verbose }) => {
title: 'Updating index.html...',
task: async () => {
let indexHtml = fs.readFileSync(rwPaths.web.html, 'utf-8')

if (
/\n\s*<script type="module" src="entry.client.tsx"><\/script>/.test(
indexHtml
)
) {
// index.html is already updated
return
}

indexHtml = indexHtml.replace(
'href="/favicon.png" />',
'href="/favicon.png" />\n <script type="module" src="entry.client.tsx"></script>'
Expand Down

0 comments on commit 83d180f

Please sign in to comment.