故事书构建成功但服务时出错

时间:2021-04-27 04:00:24

标签: storybook

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

empty spinner

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

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
      }),
    }
  }
}

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].*" },
}

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

有没有人遇到过这个问题?你能帮我修一下吗? 之前非常感谢!

3 个答案:

答案 0 :(得分:1)

您是否要部署它来放大?

答案 1 :(得分:0)

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

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

答案 2 :(得分:0)

当我遇到这个问题时,我使用 npx serve -s 开始静态文件服务。

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