Skip to content

[Bug]: html.template does not support public folder as expected #2815

@Romej

Description

@Romej

Version

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M1
    Memory: 494.88 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Brave Browser: 109.1.47.186
    Chrome: 126.0.6478.127
    Edge: 126.0.2592.87
    Safari: 17.5
  npmPackages:
    @rsbuild/core: 1.0.0-alpha.4 => 1.0.0-alpha.4 
    @rsbuild/plugin-node-polyfill: ^1.0.1 => 1.0.1 
    @rsbuild/plugin-react: 1.0.0-alpha.4 => 1.0.0-alpha.4 
    @rsbuild/plugin-svgr: ^1.0.0-alpha.4 => 1.0.0-alpha.4 
    @rsbuild/plugin-type-check: ^1.0.0-alpha.4 => 1.0.0-alpha.4

Details

Given the following config:

export default defineConfig({
  html: {
    template({ entryName }) {
      const templates = {
        foo: './public/index.html',
        bar: './public/bar.html',
      };
      return templates[entryName] || './public/index.html';
    },
  },
  source: {
    entry: {
      foo: './src/index.tsx',
      bar: './src/bar/index.tsx',
    },
  }
  ...

Then rsbuild will correctly display the http://localhost:3000/foo page.
But http://localhost:3000/bar will show a blank page.

It appears rsbuild is able to render a page in the public folder if the template file is called index.html
However, any other name such as bar.html will result in a blank page.

Does rsbuild support the public folder or is it necessary to migrate from public to static for it to work as expected ?

Reproduce link

https://github.com/Romej/rsbuild-public-entries

Reproduce Steps

  1. install deps with yarn
  2. run yarn dev
  3. go to http://localhost:3000/foo (should render because template is called index.html)
  4. go to http://localhost:3000/bar (should see blank page because template is called bar.html)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions