storybook CLI:支持已知的构建器和渲染器,但不支持未知的框架,

kd3sttzy  于 3个月前  发布在  其他
关注(0)|答案(6)|浏览(55)

在Storybook 7.0中,我们引入了概念Frameworks,它包括完全指定的故事书配置,如渲染器(例如preact)、构建器(例如vite)和其他一些预设。
我们最近更新了CLI以处理这种新结构在sb init/sb repro/等中的新代码。然而,当找不到与用户配置匹配的框架时,新代码会抛出错误。相反,它应该具有一些回退行为,待定。这种行为应与即将设计的“框架弹出”功能保持一致。

建议

core: {
  builder: 'builder-name',
  renderer: 'renderer-name',
}

为了支持这一点,我们需要添加对新字段core.renderer的支持,该字段实际上是另一个插件放置在addons的内容之前(就像framework已经实现一样)。core.builder已经得到支持。

wgxvkvu9

wgxvkvu91#

In cases where there isn't a predefined version, perhaps the CLI can ask the user to eject their own custom pair of renderer & builder?

This project uses Marko and Vite. Storybook doesn't have an automatic configuration for this pair of libraries yet.
Would you like to create your own configuration?
Y/N

#if marko renderer exists
	We found a Marko renderer to render your component. Add it to your config?
	Y/N
#else 
	We couldn't find a renderer for your component. Choose from an existing renderer or create your own.
	[ React, HTML, Vue, etc..., Create your own »]
# endif

#if Vite builder exists
	We found a Vite builder to build your component code. Add it to your config?
	Y/N
#else 
	We couldn't find a builder for your component. Choose from an existing builder or create your own.
	[Webpack4, Webpack5, Snowpack, etc..., Create your own »]
# endif
8wigbo56

8wigbo562#

有任何机会它会被修复吗?

oxiaedzo

oxiaedzo3#

对于任何在此工作的人,用户最终会出现以下错误信息:
Sorry, for now, you can not do this, please use a framework such as @storybook/react-webpack5
这里是位置:baseGenerator。我们应该尝试让CLI更具交互性,就像Dom在上面提出的建议一样!

w1e3prcc

w1e3prcc4#

你好,大家好!👋感谢你们在CLI错误中提到这个问题。目前有没有一种临时的解决方法?

我在一个干净的vite应用中看到了这个问题:

npx sb init --builder @storybook/builder-vite

Need to install the following packages:
  sb@7.0.11
Ok to proceed? (y) 

 storybook init - the simplest way to add a Storybook to your project. 

 • Detecting project type. ✓
(node:39669) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
 • Adding Storybook support to your "React" app
     Error: Sorry, for now, you can not do this, please use a framework such as @storybook/react-webpack5

https://github.com/storybookjs/storybook/issues/18360
    at baseGenerator (/Users/hi-matbub/.npm/_npx/d28cfb4b54958d89/node_modules/@storybook/cli/dist/generate.js:42:11013)
    at async generator3 (/Users/hi-matbub/.npm/_npx/d28cfb4b54958d89/node_modules/@storybook/cli/dist/generate.js:50:5065)
    at async installStorybook (/Users/hi-matbub/.npm/_npx/d28cfb4b54958d89/node_modules/@storybook/cli/dist/generate.js:332:791)
    at async doInitiate (/Users/hi-matbub/.npm/_npx/d28cfb4b54958d89/node_modules/@storybook/cli/dist/generate.js:337:707)
    at async withTelemetry (/Users/hi-matbub/.npm/_npx/d28cfb4b54958d89/node_modules/@storybook/core-server/dist/index.js:35:3422)
    at async initiate (/Users/hi-matbub/.npm/_npx/d28cfb4b54958d89/node_modules/@storybook/cli/dist/generate.js:348:109)

如果需要的话,这是仓库链接:https://github.com/9mbs/connect-readme/tree/main/workspaces/components

b0zn9rqh

b0zn9rqh5#

嘿,@9mbs,你能试一下npx storybook@latest init吗?配置应该能自动检测到,或者你会收到一个提示,所以不再需要传递--builder了。你还能告诉我在哪里得到npx sb init --builder @storybook/builder-vite命令的吗?

6yt4nkrj

6yt4nkrj6#

Yowza!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.12 containing PR #22559 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb@latest upgrade

相关问题