-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Setting paths.base in svelte.config.js causes adapter-static to fail (404) #4528
Comments
replicated - not sure if this is worth noting but right now my workaround is only using relative links ( |
Oh really? I just tried with and both give the same error. In fact, the error for So, I can't reproduce your workaround unfortunately... P.S. I also removed |
Try with a |
Thanks, will do!! |
just tried with the skeleton build and latest (kit v328 and static v30) and reproduced the 404. |
I also ran into this bug, and had a quick discussion with @mrkishi who confirmed this being a bug. To replicate, simply create a new SvelteKit demo application, add adapter-static and set This is true for current versions:
|
works Working repro: https://github.com/DougAnderson444/test-static-adapter-versions Working combination:
Clone, build, then change to |
@DougAnderson444 I believe that issue was fixed by #4928 in 1.0.0-next.331 |
@metonym you are right, .331 works!! Thanks! :) |
I have this exact issue with the following configuration.
Build fails with |
I managed to find a workaround by importing <script>
import { base } from '$app/paths';
</script>
<a href="{base}/">Home</a>
<a href="{base}/about">About</a> |
Issue still occurs for -> @sveltejs/kit@1.0.0-next.357 |
this save my life, the error during |
The "workaround" shown above is the correct solution (and to not write it everytime, you could abstract it away into a component). There is no way to make this work as expected otherwise. Doing something like An alternative is to add a I therefore switched the tag to "documentation" - we need to better document this, and the error message could probably get some more details or a link to the docs. |
* [docs] explain ramifications of base path Closes #4528 * changeset * docs * Update packages/kit/types/ambient.d.ts Co-authored-by: Conduitry <git@chor.date> * Update documentation/docs/16-configuration.md Co-authored-by: Conduitry <git@chor.date> * Update packages/kit/types/ambient.d.ts Co-authored-by: Geoff Rich <4992896+geoffrich@users.noreply.github.com> Co-authored-by: Conduitry <git@chor.date> Co-authored-by: Geoff Rich <4992896+geoffrich@users.noreply.github.com>
turns out relative route would not work. now using absolute path with `base`. (reference: sveltejs/kit#4528)
Hi, I'm having the same issue, and already figured out I had to append However, the error doesn't point to a location in my code, so I'll never know if I miss one link or not. Any ideas? |
This was a odd one, but posting here in case others have the same issue. If you receive the following build error:
And have prefixed all links with
The Reason and pitfall here is that you somewhere have: For me at least, this was not easy to understand as the error code, while completely correct, does not point to anything in the codebase or include a warning that this can be cause by a link ending in Edit
Which will allow you to abstract all this away and do: Hope this might help someone. |
Fix for [this issue](sveltejs/kit#4528). Also, see [svelte paths doc](https://kit.svelte.dev/docs/configuration#paths).
Describe the bug
adapter-static
fails when I runnpm run build
and I have setpaths.base
to some path (as intended to eventually deploy on GitHub pages). The build process returns a 404 as it cannot find the appropriate routes or static resources.Reproduction
I created an empty project to reproduce the behavior. I am using the
adapter-static
to build a production version of the site. I followed the steps from the ReadMe.I have created 1 additional route:
/a/index.svelte
In the root index
/index.svelte
I created a reference to this route:<a href="/a" title="a link">a link</a>
as well as a reference to an image (the already present favicon):
<img alt="course-title" src="favicon.png" />
Commenting out either one of the produces the same error. The build process stops when the first error occurs, but it seems it is regardless of whether it's a route or static resource reference.
The error is:
404 /a (linked from /your-repo-name)
or
404 /favicon.png (linked from /your-repo-name)
In
svelte.config.js
I have setpaths.base
to/your-repo-name
, basically a copy of the description in the ReadMe foradapter-static
. Setting thispaths.base
to an empty string does not produce the error. Also settingprerender
tofalse
also doesn't produce the error, but obviously, that's not what I want here.Logs
package.json:
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: