-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
I've been trying to export my site and and deploy an ssg build to a subpath, but it seems that currently only root deployments are supported (this limitation is not mentioned in the docs).
After spending some time to figure out how the ssg template generation works, I managed to patch my build process to make all paths work correctly when deploying to a subpath.
I would like to submit a PR to webstudio to improve the ssg template and bring this feature to everyone, and I am here to check in with the maintainers and agree on a solution (I wanted to reach out on discord but the invite link in the docs is invalid).
Thanks a lot!
What I did so far
Note that I mostly work with infrastructure, pipelines and automations, and UI components are not my strongest case :).
CSS and JS assets are covered by setting the base option in vite.
Navigation links in app/__generated__/* files use the Link component which currently does not support prefixing with a base path during build time.
- I wrote a very basic
vitepre-build hook that prefixes values ofhrefattributes. - I am not sure how to implement this correctly because the
Linkcomponent is marked as@deprecated.
Image URLs are run through the imageLoader during the build, but it passes the given file path through without modifications.
- I fixed this by prefixing the given
srcwithimport.meta.env.BASE_URL.
Other assets like the social image, favicon, fonts and background images inside the +Head.tsx component are both passed through the imageLoader without modifications and prefixed with the assetBaseUrl.
- I fixed this by introducing a new
assetLoadernext to theimageLoaderwhich prefixes the given path with both the base path and theassetBaseUrl. With this, the component does not need to importassetBaseUrlanymore.