Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Leading slash (root relative links) in index.html break deployment outside of document root #238

Open
KonradHoeffner opened this issue Apr 27, 2021 · 3 comments

Comments

@KonradHoeffner
Copy link

I'm sure this breaks the builds of many other newcomers to Svelte:
After npm run build, both deployment of the public folder as well as running index.html in the browser fails, because the links to all root-relative.
So the only way Svelte can be deployed with the template as it is currently, is in the document root of a webserver.
As it works perfectly with relative links both in the root and from any other location (both over a webserver and using the file protocol locall), and I see no downside of using them, I submit a pull request to make the links relative. Please correct me if I'm wrong here.

@KonradHoeffner
Copy link
Author

P.S.: I don't normally create pull requests, please tell me if I there is anything I should do differently in the pull request workflow.

@KonradHoeffner KonradHoeffner changed the title Leading slash (root relative links) in index.html break deployment Leading slash (root relative links) in index.html break deployment outside of document root Apr 27, 2021
@Conduitry
Copy link
Member

The purpose of the absolute paths is to support single-page apps, where the js/css files won't necessarily be in the current directory as the browser understands it. We could maybe improve the readme, but I don't think we should simply change the URLs.

@KonradHoeffner
Copy link
Author

Maybe I understand something wrongly here, but isn't a single-page app one where there is just a single index.html file in the public folder where the paths work out? I would expect this problem to only occur in a multi-page app, where there are multiple pages in different folders and folder nesting depths.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants