Storybook docs-only pages not loading without Story #30185
-
SummaryI have Storybook pages that only contain docs with no stories or Ever since upgrading to Storybook v8, I had to change my Now, no MDX files are loading unless there's an associated story available in the Even if I do add a story, I receive an error:
How am I supposed to have docs-only pages in Storybook using MDX files that didn't have an accompanying stories file and aren't associated with component stories? Additional information
/*!
* Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and limitations under the License.
*/
import type { StorybookConfig } from "@storybook/react-vite";
import { dirname, join } from "node:path";
/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
const getAbsolutePath = (value: string): any => {
return dirname(require.resolve(join(value, "package.json")));
};
const config: StorybookConfig = {
addons: [
{
name: "@storybook/addon-docs",
options: {
transcludeMarkdown: true,
},
},
getAbsolutePath("@storybook/addon-links"),
getAbsolutePath("@storybook/addon-a11y"),
getAbsolutePath("@storybook/addon-essentials"),
getAbsolutePath("@storybook/addon-interactions"),
getAbsolutePath("@storybook/addon-mdx-gfm"),
// getAbsolutePath("storybook-addon-rtl-direction"),
],
core: {
builder: "@storybook/builder-vite",
disableTelemetry: true,
},
docs: {
autodocs: true,
},
framework: {
name: getAbsolutePath("@storybook/react-vite"),
options: {},
},
stories: ["../src/**/*.stories.@(js|jsx|ts|tsx)", "../src/**/*.mdx"],
typescript: {
check: false,
reactDocgen: "react-docgen-typescript",
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: (prop) => {
if (!prop.parent) return true;
return (
/odyssey-react-mui/.test(prop.parent.fileName) ||
!/node_modules/.test(prop.parent.fileName)
);
},
},
},
staticDirs: ["../src/static"],
};
export default config;
"@pxblue/storybook-rtl-addon": "^1.1.0",
"@storybook/addon-a11y": "^8.4.5",
"@storybook/addon-essentials": "^8.4.5",
"@storybook/addon-interactions": "^8.4.5",
"@storybook/addon-links": "^8.4.5",
"@storybook/addon-mdx-gfm": "^8.4.5",
"@storybook/blocks": "^8.4.5",
"@storybook/components": "^8.4.5",
"@storybook/core-events": "^8.4.5",
"@storybook/manager-api": "^8.4.5",
"@storybook/preview-api": "^8.4.5",
"@storybook/react": "^8.4.5",
"@storybook/react-vite": "^8.4.5",
"@storybook/test": "^8.4.5",
"@storybook/test-runner": "^0.19.1",
"@storybook/theming": "^8.4.5",
"@types/mdx": "^2.0.11",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"storybook": "^8.4.5",
"storybook-addon-rtl-direction": "^0.0.19",
"typescript": "^5.6.3",
"vite": "^5.4.11", No error messages unless I purposefully try to break it, it just doesn't load stories files without a story. Your reproduction works, but mine is not. Create a reproductionNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The solution appears to be that the codemod broke it. I don't want the |
Beta Was this translation helpful? Give feedback.
The solution appears to be that the codemod broke it.
I don't want the
.stories.ts
files. You can add.mdx
by itself tomain.ts
(per your sandbox example). All I needed to do was to change.stories.mdx
to.mdx
, and it would've worked fine. For some reason, the codemod changed these files and removed theMeta
at the top causing this problem.