template icon indicating copy to clipboard operation
template copied to clipboard

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

Open KonradHoeffner opened this issue 4 years ago • 3 comments

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 avatar Apr 27 '21 09:04 KonradHoeffner

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 avatar Apr 27 '21 09:04 KonradHoeffner

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.

Conduitry avatar Apr 27 '21 12:04 Conduitry

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.

KonradHoeffner avatar Apr 27 '21 12:04 KonradHoeffner