Storybook 构建成功,但服务时出错

And*_*ian 5 storybook

我在提供构建的故事书时遇到了问题。正如你在下面看到的,它只显示了一个旋转器旋转到遗忘状态。当我打开控制台时,它显示: Error: manager received sharedStateChanged-manager-storybook/viewport but was unable to determine the source of the event

空旋转器

这是我的故事书配置文件:

main.js

module.exports = {
  stories: [
    "../src/**/*.stories.mdx",
    "../src/**/*.stories.@(js|jsx|ts|tsx)"
  ],
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/preset-create-react-app"
  ],
  webpackFinal: config => {
    return {
      ...config,
      plugins: config.plugins.filter(plugin => {
        if (plugin.constructor.name === 'ESLintWebpackPlugin') {
          return false
        }
        return true
      }),
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

preview.js

import '../src/recore/.storybook/preview.css'
import * as Recore from '../src/recore'

Recore.init({
  defaults: {
    IMAGE_RESOLVER: path => {
      return import('../src/assets/' + path)
    }
  }
})

export const parameters = {
  actions: { argTypesRegex: "^on[A-Z].*" },
}
Run Code Online (Sandbox Code Playgroud)

为了构建故事书,我运行了build-storybook -o ./build -s ./public -c .storybook I am using npm,它告诉我要这样做,npm run build-storybook -- -o ...但它的行为并不符合预期。另外,我目前使用"@storybook/react": "^6.1.21"

以前有人遇到过这个问题吗?你能帮我修复它吗?之前非常感谢!

小智 6

当我遇到这个问题时,我开始使用npx serve -s.

更改启动以npx serve解决问题(这是托管在 Azure 中的 Linux Web 应用程序上)。


小智 2

添加 "@storybook/builder-webpack5": "^6.2.9",

https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324