dai-shi / waku

⛩️ The minimal React framework
https://waku.gg
MIT License
3.91k stars 102 forks source link

fix: non js assets path should add config.basePath to be relative to root path #697

Closed PerfectPan closed 1 week ago

PerfectPan commented 1 week ago

Solve https://github.com/dai-shi/waku/issues/649.

I did some research based on https://github.com/dai-shi/waku/pull/674. The root cause is that css path in html missing / so that when brower try to join the real path, it will use the current path instead of root path.

CleanShot 2024-05-05 at 00 44 55@2x

CleanShot 2024-05-05 at 00 45 27@2x

vercel[bot] commented 1 week ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
waku ✅ Ready (Inspect) Visit Preview May 5, 2024 2:54am
codesandbox-ci[bot] commented 1 week ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

PerfectPan commented 1 week ago

Thanks for investigating into it! It looks valid. We use basePath instead of /. (Though, we don't have tests and changing basePath in config might not fully work, yet. Contributions are welcome.)

I totally ignore the basePath option lol. I have already changed the code.

For changing basePath in config, I tried and it seems not working well.

CleanShot 2024-05-05 at 10 58 35@2x

This may involve the paths of resources in HTML files, the paths of generated files, and the paths for server hosting static resources. It seems that something is not quite right with all of them.

CleanShot 2024-05-05 at 11 03 06@2x

CleanShot 2024-05-05 at 11 04 29@2x

Would you mind I open an another issue to follow this and try to add test cases and solution later?

dai-shi commented 1 week ago

Yeah, we have the basePath config but it's never used in cli.ts. (I guess it would be app.use('/test/*', ...).)

Please open a new issue and maybe our first target would be SSG.