Fix the service worker not loading in dev mode
This commit is contained in:
@@ -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/**"
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
"vitest": "^2.1.8"
|
||||
},
|
||||
"msw": {
|
||||
"workerDirectory": [".storybook"]
|
||||
"workerDirectory": [".storybook/public"]
|
||||
},
|
||||
"overrides": {
|
||||
"swagger-ui-react": {
|
||||
|
||||
Reference in New Issue
Block a user