Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/empty-hands-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: ensure `base` is available from `$service-worker` during development
1 change: 1 addition & 0 deletions packages/kit/src/exports/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,7 @@ const create_service_worker_module = (config) => dedent`
throw new Error('This module can only be imported inside a service worker');
}

export const base = location.pathname.split('/').slice(0, -1).join('/');
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is taken from the prod version of base

const base = "location.pathname.split('/').slice(0, -1).join('/')";

export const build = [];
export const files = [
${create_assets(config)
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/apps/options-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"prepare": "svelte-kit sync",
"check": "svelte-kit sync && tsc && svelte-check",
"test": "pnpm test:dev && pnpm test:build",
"test:dev": "DEV=true playwright test",
"test:dev": "DEV=true playwright test && REGISTER_SERVICE_WORKER=true DEV=true playwright test",
"test:build": "playwright test && REGISTER_SERVICE_WORKER=true playwright test"
},
"devDependencies": {
Expand Down
Loading