-
-
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
Build an output that is usable from local disk (file:// URL) #907
Comments
@jzillmann Re your current |
@btakita Not sure what you mean... |
@jzillmann How are you currently routing to the different "page" components in the SPA? I wonder if it's feasible to extract only the Sveltekit router to use with Classic Svelte & Vite. --- Edit I'm going to try to add use |
Oh, I guess i just do customized routing, nothing special there! |
This issue is essential for Electron apps, which use the filesystem. All the links and scripts in the page are absolute, so it doesn't work. |
Just a heads-up. I'm working on a fork of Sapper to support My current work in progress is at https://github.com/btakita/sapper/tree/hbr I had to attend to some other priorities & will continue with the hbr branch over the next couple of days. |
@benmccann I was able to modify the routing to switch between hash-based routing when the origin is When the time comes to migrate my project over to Svelte Kit, I'll work on a PR. The conditionals are spread out in several places in https://github.com/btakita/sapper/blob/hbr/runtime/src/app/router/index.ts & https://github.com/btakita/sapper/blob/hbr/runtime/src/app/goto/index.ts. I didn't want to do any major refactorings, lest the hbr branch diverge too far from the master branch. |
This comment has been minimized.
This comment has been minimized.
I've tried installing the |
This comment has been minimized.
This comment has been minimized.
After a lot of tinkering I have managed to build a script that can take an html-file generated by adapter-static and inline all javascript in the file. It is very hacky and runs code in the browser to make the imports work, but it works for my use-case which is to build simple html-files with a bit of interactivity in them that I can send in an email without hosting them anywhere. Might be useful as inspiration for someone. The trickiest part is that the only way I could use https://github.com/mattiash/svelte-notebook/blob/master/util/inlinejs.cjs |
I also came up with a hacky workaround for a similar issue including hash routing, not sure if it's specific to
|
This might what ya all are looking for: from #2042 (comment) (has example) |
I hope this is the correct issue to comment on. My use-case is similar, even though I don't need it to work standalone with I am trying to make a my application work within an electron app. For that, I found that if I was not using SvelteKit, I could configure vite with When I leave |
@till it would seem that SvelteKit always sets base to kit/packages/kit/src/exports/vite/index.js Line 431 in cad0389
Is there anything you notice being different in the output between a normal Vite build with |
@benmccann Maybe I am using it wrong, or using not the latest? I just upgraded to a When I set |
Hmm, looking at the code, maybe |
The file references are relative now:
Yep. It looks like this is the main blocker: IIFE requires that we have only a single input, so in IIFE mode we would need to tweak that: kit/packages/kit/src/exports/vite/index.js Line 407 in 74798e9
This is highly related to #3882. I'm not entirely sure what will be required to support IIFE beyond that. Probably we should try to use IIFE only on the client. |
Is your feature request related to a problem? Please describe.
Quite often i code tools which take some input (like a JSON file) and generate a HTML report out of it. This HTML report might be served by a server (e.g. Github Pages) but often just sits somewhere on the disk and should be openable/consumable from there (e.g.
open file:///Users/x/projects/y/build/test/index.html
).Describe the solution you'd like
From initial experiments (with
adapter-static
) I found 2 things I would need for the above to work which I failed to accomplish withsvelte-kit
so far:index.html
) need to be relative instead of absolutepaths/assets||base
were quite resistant setting up anything relativeIIFE
format (since module script imports will raise CORS issues)vite.build: { lib: { name: "my-app", entry: "src/main.ts", formats: ["iife"] }}
producedUMD and IIFE output formats are not supported for code-splitting builds
A solution would be to make the 2 things possible.
Perfect would be a simple way to achieve that. Like an specialized adapter.
Describe alternatives you've considered
Maybe what I'm trying to achieve is dump and using svelte-kit for such a thing doesn't make much sense? Just stick to
Svelte Classic
?With
Svelte Classic
and Vite I can accomplish the above by tweakingvite.config.js
in the following way:base
to''
(makes the links relative)IIEF
format:index.html
topublic/
and add appropriate script and css includesHow important is this feature to you?
This is the first thing I usually set up for the majority of apps I'm crafting.
The text was updated successfully, but these errors were encountered: