Skip to content

Commit 83d180f

Browse files
authored
RSC: Check if index.html has already been updated during setup (#9197)
With this check in place it's now safe to run the setup command multiple times, which is great when testing it.
1 parent e2c14eb commit 83d180f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

packages/cli/src/commands/experimental/setupRscHandler.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ export const handler = async ({ force, verbose }) => {
158158
title: 'Updating index.html...',
159159
task: async () => {
160160
let indexHtml = fs.readFileSync(rwPaths.web.html, 'utf-8')
161+
162+
if (
163+
/\n\s*<script type="module" src="entry.client.tsx"><\/script>/.test(
164+
indexHtml
165+
)
166+
) {
167+
// index.html is already updated
168+
return
169+
}
170+
161171
indexHtml = indexHtml.replace(
162172
'href="/favicon.png" />',
163173
'href="/favicon.png" />\n <script type="module" src="entry.client.tsx"></script>'

0 commit comments

Comments
 (0)