Description
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 with svelte-kit
so far:
- Links/Includes (from
index.html
) need to be relative instead of absolutepaths/assets||base
were quite resistant setting up anything relative
- The JS field need to be in
IIFE
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 tweaking vite.config.js
in the following way:
- Set
base
to''
(makes the links relative) - Configure
IIEF
format:
build: {
lib: { name: "my-app", entry: "src/main.ts", formats: ["iife"] },
}
- Move the
index.html
topublic/
and add appropriate script and css includes
How important is this feature to you?
This is the first thing I usually set up for the majority of apps I'm crafting.