🐛 BUG: AstroUserConfig.base does not apply to assets in public folder
What version of astro are you using?
1.0.0-rc.3
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Windows
Describe the Bug
The property base on AstroUserConfig does not apply to assets in the public folder. This made for some fun debugging with Github pages. I'm not sure if this is by design or not though. If it's by design, a note should probably be made in the documentation about it.
For example, given the base config of:
import { defineConfig } from 'astro/config';
export default defineConfig({
site: "https://astro.github.io",
base: "/my-project"
});
A file in the public dir as such public/make-scrollable-code-focusable.js would compile to:
<script src="/make-scrollable-code-focusable.js">
When the expected result is as such:
<script src="/my-project/make-scrollable-code-focusable.js">
Link to Minimal Reproducible Example
https://astro.new/docs?on=stackblitz
Participation
- [ ] I am willing to submit a pull request for this issue.
Hi @daymxn! Would you be able to provide a link to your code reproduction so we can debug this? Looks like you're reproduction link is just the default docs starter.
Hello @delucis,
This is a big issue for us as we need to deploy on a custom base.
To add a bit on what @daymxn said, it seems that any link in the template of a page is not updated by the base when building.
As an exemple any <a> tag href nor <img> tag src is not updated either.
Here is a reproduction with comments to help you figure out what is happening and what should be happening: https://stackblitz.com/edit/github-xf1evk?file=src/pages/index.astro
I hope this can help fix this issue. Have a great day.
Still in needs-repro any update @delucis?
Have a great day.
Astro does not modify your HTML. If your script tags need a base you need to add it to the tag yourself, just directly write:
<script src="/my-project/make-scrollable-code-focusable.js">
This should work in dev and prod, if it doesn't let me know.
Going to go ahead and close this, but happy to continue chatting here.