Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SvelteKit application overfile:// protocol#12206

Unanswered
jerivas asked this question inQ&A
Discussion options

Hello! For reasons outside of our control, we require our SvelteKit app to work over thefile:// protocol. The goal is to build the app, transfer files to client machines, and have them use it by launchingindex.html.

The biggest obstacle so far is thatbrowsers refuse to load ESM scripts overfile:// URLs, which means all JS is being blocked. It looks like Vite can be configured to targetes5, but that also would remove modern JS syntax likelet andconst, which is not desired. I also looked into legacy builds, but support for them is currently anopen issue.

I have prepared ademo repo configured to build the Svelte Kit demo app with the static adapter. You can try it yourself by building it and pointing your browser directly tobuild/index.html. You will get a blank screen and errors in the console:

image

You must be logged in to vote

Replies: 2 comments 8 replies

Comment options

Any Solution to this? Having the same problem rn... would be glad for any help :(

You must be logged in to vote
0 replies
Comment options

In newer Kit versions you can setoutput.bundleStrategy to'inline' (output docs) and remove Vite'sbuild.assetsInlineLimit by setting it to a large value/Infinity.

To make routing work, set therouter.type tohash (router docs). The links in the application will accordingly have to use#/route/here.

You must be logged in to vote
8 replies
@brunnerh
Comment options

The build command should output a standalone file (with possibly a few non-essential files).
The intermediate files should all be somewhere in the.svelte-kit directory.

It looks like something is off in your case. Maybe the library has something to do with it, not sure.

Ideally create a minimal reproduction and ask a separate question, providing all the necessary files.

@Unknown78
Comment options

Is it SSG or SPA? Is SSG possible?

@brunnerh
Comment options

It's fully static, see e.g. the linked example further up.

@Unknown78
Comment options

https://svelte.dev/docs/kit/configuration#router

What type of client-side router to use.

'pathname' is the default and means the current URL pathname determines the route
'hash' means the route is determined by location.hash. In this case, SSR andprerendering are disabled. ...


Does that mean that it is SPA?
I don't understand the rationale behind the use ofhash router type instead of the usualpathname.

@brunnerh
Comment options

It effectively is an SPA, though most SPAs would still pull data from some server instead of rendering it into the page on the server. Here the entire static application is in a single file, which requires hash-based routing.

I don't know if the inline bundle strategy can work without this, i.e. having it generatemultiple independent HTML files that inline their own JS & CSS. I suspect that this is not possible, though.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
4 participants
@jerivas@brunnerh@genaray@Unknown78

[8]ページ先頭

©2009-2025 Movatter.jp