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: public folder doesn't get copied to subpath if buildOptions.site is provided in development #2409

Closed
RafidMuhymin opened this issue Jan 17, 2022 · 7 comments

Comments

@RafidMuhymin
Copy link
Member

What version of astro are you using?

0.22.13

What package manager are you using?

yarn

What operating system are you using?

Ubuntu

Describe the Bug

The /public folder doesn't get copied to the subpath if the buildOptions.site config option is provided. The bug is present only in development mode. It works fine in production.

Link to Minimal Reproducible Example

https://astro.new/subpath?on=stackblitz

@github-actions github-actions bot added this to Needs Triage in 🐛 Bug Tracker Jan 17, 2022
@RafidMuhymin RafidMuhymin changed the title 🐛 BUG: public folder doesn't get copied to the subpath if buildOptions.site is provided in development 🐛 BUG: public folder doesn't get copied to subpath if buildOptions.site is provided in development Jan 17, 2022
@tadeuzagallo
Copy link
Contributor

I started trying to fix this in #2348, but it needs more work

@jonathantneal jonathantneal moved this from Needs Triage to Accepted in 🐛 Bug Tracker Jan 19, 2022
@jonathantneal
Copy link
Contributor

I’m sorry you’re running into this. As @tadeuzagallo mentioned, this is a known issue, and we are working on it.

@sueharaluke
Copy link

Here's a work around that I'm currently using:
https://stackblitz.com/edit/github-ttgbip?file=astro.config.mjs

Points to be aware of:

  • I couldn't get process.env.NODE_ENV working inside astro.cong.mjs, so I added cross-env package and prefixed the scripts
  • public folder assets must also be inside the subfolder

Hope it helps someone.

@tony-sull
Copy link
Contributor

Closed out a few duplicate issues to use this as the primary since it's the oldest

Confirmed this still reproduces with the lastest beta - clone the subpath starter and run npm run build && npm run preview

Comparing against Vite's base behavior, it looks like the only fix needed is to include the base path in any assets at build time. dev and preview work as expected so hopefully this is an easy one to take care of 🤞

@tony-sull
Copy link
Contributor

Expected behavior:

astro dev - base is ignored, all page URLs and asset paths are redirected internally

astro build - all assets are built to dist/assets, HTML src and hrefs all include the base, i.e. src="/blog/assets/img.asdf.jpg

astro preview - preview server respects the base path, all URLs are redirected from /subpath/... to /... internally (so assets are found in dist/assets)

@Auroratide
Copy link

Was poking around and noticed some work was happening on this front! Noting here as reference:

In fact my minimal reproduction now loads assets correctly.

@tony-sull
Copy link
Contributor

Looks like I missed closing this with the latest for subpaths, glad this is fixed now!

🐛 Bug Tracker automation moved this from Accepted to Done May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

8 participants