Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Romej opened this issue Jul 5, 2024 · 0 comments
Closed

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

Romej opened this issue Jul 5, 2024 · 0 comments
Assignees
Labels
🐞 bug Something isn't working

Comments

@Romej
Copy link
Contributor

Romej commented Jul 5, 2024

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)
@Romej Romej added the 🐞 bug Something isn't working label Jul 5, 2024
@chenjiahan chenjiahan self-assigned this Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants