Skip to content

Commit

Permalink
Troubleshooting GH Pages SW (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessbell authored Jun 14, 2024
1 parent c0eb0ad commit 5e9e6d3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import graphqlLoader from "vite-plugin-graphql-loader";

const config: StorybookConfig = {
stories: ["./**/*.mdx", "./**/*.stories.@(js|jsx|mjs|ts|tsx)"],
staticDirs: ["../public"],
staticDirs: ["./public"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
Expand Down
24 changes: 5 additions & 19 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,18 @@ import type { Preview } from "@storybook/react";
import { initialize, mswLoader, getWorker } from "msw-storybook-addon";
import "./stories/input.css";

let options = {};

if (location.hostname === "apollographql.github.io") {
options = {
serviceWorker: {
url: "/graphql-testing-library/mockServiceWorker.js",
},
};
}

// Initialize MSW
initialize(options);
initialize({
serviceWorker: {
url: './mockServiceWorker.js'
}
});

const preview: Preview = {
// calling getWorker().start() is a workaround for an issue
// where Storybook doesn't wait for MSW before running:
// https://github.com/mswjs/msw-storybook-addon/issues/89
loaders: [mswLoader, () => getWorker().start()],
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
},
"msw": {
"workerDirectory": [
"public"
".storybook/public"
]
},
"relay": {
Expand Down

0 comments on commit 5e9e6d3

Please sign in to comment.