Skip to content

fix(core): avoid filename conflict when static/index.html is used (AI… - #13105

Open
PranavSharma124 wants to merge 1 commit into
meta:mainfrom
PranavSharma124:fix/dev-html-static-index-conflict
Open

PranavSharma124 wants to merge 1 commit into
meta:mainfrom
PranavSharma124:fix/dev-html-static-index-conflict

Conversation

@PranavSharma124

@PranavSharma124 PranavSharma124 commented Nov 23, 2026 •

Copy link
Copy Markdown

…-assisted)

Emit the dev HTML shell to '__docusaurus.html' and route devServer historyApiFallback to it, avoiding asset conflicts with user-provided static/index.html.

Fixes #10198

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Test Plan

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

Summary by CodeRabbit

  • Bug Fixes
    • Fixed development server routing so pages load correctly when the site is hosted at the root or under a subpath.
    • Prevented the development server’s generated HTML from overwriting a project’s existing index.html.

…-assisted)

Emit the dev HTML shell to '__docusaurus.html' and route devServer historyApiFallback to it, avoiding asset conflicts with user-provided static/index.html.

Fixes meta#10198
@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The development HTML shell now uses __docusaurus.html by default. The dev-server history fallback targets that file at the root or configured subpath, leaving a static index.html available as a separate output.

Changes: Development HTML shell

Layer / File(s) Summary
Set the development shell filename
packages/docusaurus/src/webpack/plugins/DevHtmlPlugin.ts, packages/docusaurus/src/webpack/client.ts, packages/docusaurus/src/webpack/plugins/__tests__/DevHtmlPlugin.test.ts
DevHtmlPlugin defaults to __docusaurus.html and accepts a custom filename. Client configuration uses the default. Tests verify the default and custom filenames, and confirm webpack and rspack preserve a static index.html while emitting the development shell separately.
Route dev-server fallback to the shell
packages/docusaurus/src/commands/start/webpack.ts, packages/docusaurus/src/commands/start/__tests__/webpack.test.ts
The history fallback rewrites to the shell filename joined with the base URL. Tests check the rewrite destination for root and subpath base URLs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested labels: pr: bug fix

Merge Risk: Minimal · up to c5fb2

The development HTML shell now uses a dedicated filename, so a project's static index.html no longer conflicts with it. The dev-server fallback routes to the new shell. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the fix (avoiding a filename conflict when static/index.html is used) and the scope (core), which matches the main change: the dev HTML shell now emits as __docusaurus.html and history…
Linked Issues check Passed [#10198] The reported error occurs because the dev HTML shell and a user-provided static/index.html both emit to index.html. The PR changes the dev shell name to __docusaurus.html through the ex…
Out of Scope Changes check Passed All changed files relate to the #10198 fix. DevHtmlPlugin.ts adds the DevHtmlFilename constant and makes filename optional with a default. client.ts drops the index.html filename override. `…
Full details: Title check

Explanation

The title names the fix (avoiding a filename conflict when static/index.html is used) and the scope (core), which matches the main change: the dev HTML shell now emits as __docusaurus.html and historyApiFallback points there. The title is somewhat truncated ("(AI…") and carries an AI-generated marker, which adds noise but does not make it off-topic.

Full details: Linked Issues check

Explanation

[#10198] The reported error occurs because the dev HTML shell and a user-provided static/index.html both emit to index.html. The PR changes the dev shell name to __docusaurus.html through the exported DevHtmlFilename constant in DevHtmlPlugin.ts. The filename: 'index.html' setting is removed from webpack/client.ts, so the shell no longer collides with the copied static file. createDevServerConfig in webpack.ts now rewrites historyApiFallback to path.posix.join(baseUrl, DevHtmlFilename), so unmatched routes resolve to the shell. Static files are served before the fallback, so static/index.html remains the landing page when src/pages/index is absent. Coding tests cover the default and custom filename, the historyApiFallback rewrite for root and subpath base URLs, and webpack and rspack integration with a copied static/index.html. The issue's build expectation is not changed by this PR, and the build path was not modified. Residual uncertainty: the changes were assessed from the PR summary and not by running the dev server.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the #10198 fix. DevHtmlPlugin.ts adds the DevHtmlFilename constant and makes filename optional with a default. client.ts drops the index.html filename override. webpack.ts exports createDevServerConfig and points the history fallback at the new file. The test files cover these changes directly. No unrelated behavior change appears in the summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0d02d562-aac6-41ad-b531-420fd21a9516
Commits

Reviewing files that changed from the base of the PR and between 809ffff and c5fb2fb.

Files selected for processing: 5

  • packages/docusaurus/src/commands/start/__tests__/webpack.test.ts
  • packages/docusaurus/src/commands/start/webpack.ts
  • packages/docusaurus/src/webpack/client.ts
  • packages/docusaurus/src/webpack/plugins/DevHtmlPlugin.ts
  • packages/docusaurus/src/webpack/plugins/__tests__/DevHtmlPlugin.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@netlify

netlify Bot commented Nov 23, 2026

Copy link
Copy Markdown

✅ [V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit c5fb2fb
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6b03cc4fb7e068c28121d6be
😎 Deploy Preview https://deploy-preview-13105--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docusaurus v3.4] index.html in static directory raises "Multiple assets emit different content to the same filename" error

1 participant