<分区>
我正在尝试构建 nextjs
项目,其中 [componentName].stories.tsx
与组件本身并排。由于这些故事中的 typescript 错误,运行 next build
失败。接下来我想忽略 storybook
文件。这可能吗?如果可以,我该怎么做?
<分区>
我正在尝试构建 nextjs
项目,其中 [componentName].stories.tsx
与组件本身并排。由于这些故事中的 typescript 错误,运行 next build
失败。接下来我想忽略 storybook
文件。这可能吗?如果可以,我该怎么做?
最佳答案
根据您的具体情况,Next.js does provide a solve :
Including non-page files in the pages directory
To colocate test files, generated files, or other files used by components in the pages directory, you can prefix the extensions with something like page.
Open next.config.js and add the pageExtensions config:
module.exports = { pageExtensions: ['page.tsx', 'page.ts', 'page.jsx', 'page.js'], }
Then rename your pages to have a file extension that includes .page (ex. rename MyPage.tsx to MyPage.page.tsx).
Note: Make sure you also rename _document.js, _app.js, _middleware.js, as well as files under pages/api/.
我们遇到了与您类似的问题,但这只是页面文件夹中故事的问题。该解决方案适用于我们的项目。
关于reactjs - 下一个构建命令不会忽略 *.stories.tsx 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71437823/