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]: should output json asset to static folder, imported by new URL #3650

Open
SoonIter opened this issue Oct 8, 2024 · 3 comments
Open
Labels
🐞 bug Something isn't working

Comments

@SoonIter
Copy link
Member

SoonIter commented Oct 8, 2024

Version

System:
OS: macOS 14.6.1
CPU: (10) arm64 Apple M1 Pro
Memory: 185.28 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Browsers:
Chrome: 129.0.6668.90
Chrome Canary: 131.0.6763.0
Safari: 17.6
npmPackages:
@rsbuild/core: ^1.0.1 => 1.0.10
@rsbuild/plugin-react: ^1.0.1 => 1.0.3

Details

If a json file is imported in the way of asset e.g: new URL, it will not be placed in the static directory, so it won't be uploaded to CDN and cause the error.

import './App.css';

const testJson = new URL('./assets/test.json', import.meta.url).href;

actual

./dist
├── 0e97e3ce1fa8f304.json
├── index.html
└── static
    ├── css
    │   └── index.e56a3ec6.css
    └── js
        ├── index.566b5367.js
        └── lib-react.a7f62b4e.js

expected

./dist
├── index.html
└── static
    ├── css
    │   └── index.e56a3ec6.css
    ├── js
    │   ├── index.566b5367.js
    │   └── lib-react.a7f62b4e.js
    └── json
        └── 0e97e3ce1fa8f304.json

Reproduce link

https://github.com/sooniter/rsbuild-dist-json-issue

Reproduce Steps

  1. pnpm install
  2. pnpm run build
@SoonIter SoonIter added the 🐞 bug Something isn't working label Oct 8, 2024
@SoonIter
Copy link
Member Author

SoonIter commented Oct 8, 2024

  1. should deal the distPath of json with module.rules
  2. should set tools.rspack.output.assetModuleFilename to dist/static/others for backup

Image

@chenjiahan
Copy link
Member

should deal the distPath of json with module.rules

Which rule, can you give an example?

should set tools.rspack.output.assetModuleFilename

How about output to dist/static/assets instead of dist/static/others, and we can provide distPath.assets to configure the path.

@chenyuan-new
Copy link

@chenjiahan i encountered the same problem. It'll be good to have distPath.assets config

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

3 participants