Fix the service worker not loading in dev mode

This commit is contained in:
Quentin Gliech
2025-01-09 11:21:55 +01:00
parent 6071b80f30
commit 98efc4813b
5 changed files with 5 additions and 7 deletions

View File

@@ -18,7 +18,7 @@
"frontend/src/gql/**",
"frontend/src/routeTree.gen.ts",
"frontend/.storybook/locales.ts",
"frontend/.storybook/mockServiceWorker.js",
"frontend/.storybook/public/mockServiceWorker.js",
"frontend/locales/*.json",
"**/coverage/**",
"**/dist/**"

View File

@@ -57,9 +57,8 @@ const config: StorybookConfig = {
},
viteFinal: async (config) => {
// Host all the assets in the root directory,
// so that the service worker is correctly scoped to the root
config.build.assetsDir = "";
// Serve the storybook-specific assets, which has the service worker
config.publicDir = ".storybook/public";
return config;
},
};

View File

@@ -18,13 +18,12 @@ import i18n, { setupI18n } from "../src/i18n";
import { DummyRouter } from "../src/test-utils/router";
import { handlers } from "../tests/mocks/handlers";
import localazyMetadata from "./locales";
import swUrl from "./mockServiceWorker.js?url";
initialize(
{
onUnhandledRequest: "bypass",
serviceWorker: {
url: swUrl,
url: "./mockServiceWorker.js",
},
},
handlers,

View File

@@ -88,7 +88,7 @@
"vitest": "^2.1.8"
},
"msw": {
"workerDirectory": [".storybook"]
"workerDirectory": [".storybook/public"]
},
"overrides": {
"swagger-ui-react": {