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
Customize output name of service worker #12159
Comments
I think this is already possible - https://kit.svelte.dev/docs/configuration#files const config = {
kit: {
files: {
serviceWorker: './path/to/sw.js',
}
}
} |
https://kit.svelte.dev/docs/configuration#files
|
@craig-jennings @eltigerchino Thanks for your reply. I apologize if my description was not clear enough. I would like SvelteKit to automatically build the service worker script and ensure it remains type-safe. I aim to change the scriptURL registered in the browser, not the location of the source code. I've tried using the const service_worker_entry_file = resolve_entry(kit.files.serviceWorker); Changing this option does not alter the output HTML or the scriptURL. I want to maintain automatic registration but change the scriptURL. Although I can manually register it to make it If I want to maintain type safety, the easier approach is to continue using SvelteKit for building, as it will generate a TypeScript configuration based on However, SvelteKit always builds into |
service-worker.js
Related TODO comment: kit/packages/kit/src/exports/vite/index.js Line 756 in c175335
|
Describe the problem
I'm trying to migrate my old React project to SvelteKit.
In my old project, I have registered a service worker in
/sw.js
, but in SvelteKit, the service worker is located in/service-worker.js
and cannot be changed.https://github.com/sveltejs/kit/blob/main/packages/kit/src/runtime/server/page/render.js#L401-L405
As a workaround, I have to add a pre-build step to build
sw.js
isolatedly, then copy it into/static
folder, but I feel it's not a good solution.Describe the proposed solution
It would be great if we can customize the location in
svelte.config.js
likes this:Alternatives considered
No response
Importance
nice to have
Additional Information
No response
The text was updated successfully, but these errors were encountered: