@ZakaryCode 我的.storybook/main.js配置如下:
const path = require('path');
module.exports = {
babel: options => ({
...options,
plugins: [
[require('babel-plugin-transform-taroapi').default, {
apis: require(require.resolve('@tarojs/taro-h5/dist/taroApis', { basedir: path.resolve(__dirname, '..') })),
packageName: '@tarojs/taro'
}],
]
}),
webpackFinal: config => ({
...config,
resolve: {
...config.resolve,
mainFields: ['main:h5', 'browser', 'module', 'jsnext:main', 'main'],
alias: {
...config.resolve.alias,
'@tarojs/taro': '@tarojs/taro-h5'
},
},
}),
reactOptions: {
fastRefresh: true,
},
"stories": [
"../src/components/**/*.stories.tsx"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials"
],
"framework": "@storybook/react",
features: {
babelModeV7: true,
},
}
运行yarn storybook 后浏览器中报如下错误:
Unexpected error while loading ./IconGroup.stories.tsx: ENABLE_INNER_HTML is not defined
ReferenceError: ENABLE_INNER_HTML is not defined
at TaroNodeImpl.bind (http://localhost:6006/vendors~main.iframe.bundle.js:16066:9)
at new TaroNode (http://localhost:6006/vendors~main.iframe.bundle.js:13937:14)
at new TaroElement (http://localhost:6006/vendors~main.iframe.bundle.js:14615:9)
at new TaroDocument (http://localhost:6006/vendors~main.iframe.bundle.js:16147:9)
at _createInstance (http://localhost:6006/vendors~main.iframe.bundle.js:44169:12)
at resolveInstance (http://localhost:6006/vendors~main.iframe.bundle.js:44189:18)
at http://localhost:6006/vendors~main.iframe.bundle.js:44289:104
at resolve (http://localhost:6006/vendors~main.iframe.bundle.js:44313:12)
at http://localhost:6006/vendors~main.iframe.bundle.js:43288:102
at Container.push../node_modules/inversify/es/container/container.js.Container._get (http://localhost:6006/vendors~main.iframe.bundle.js:43279:44)
error @ index.js:56
(anonymous) @ executeLoadable.js:57
(anonymous) @ executeLoadable.js:51
executeLoadable @ executeLoadable.js:50
executeLoadableForChanges @ executeLoadable.js:99
getProjectAnnotations @ start.js:123
(anonymous) @ index.js:217
_runResolutions @ index.js:214
then @ index.js:67
getProjectAnnotationsOrRenderError @ PreviewWeb.js:140
initialize @ PreviewWeb.js:118
configure @ start.js:148
configure @ index.js:21
(anonymous) @ generated-stories-entry.js:6
./generated-stories-entry.js @ generated-stories-entry.js:6
__webpack_require__ @ bootstrap:853
fn @ bootstrap:150
0 @ storybook-init-framework-entry.js:1
__webpack_require__ @ bootstrap:853
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.iframe.bundle.js:1
index.js:56 Unable to load story 'icongroup--default':
error @ index.js:56
renderStoryLoadingException @ PreviewWeb.js:1374
_callee3$ @ PreviewWeb.js:322
tryCatch @ runtime.js:63
invoke @ runtime.js:294
(anonymous) @ runtime.js:119
asyncGeneratorStep @ PreviewWeb.js:8
_next @ PreviewWeb.js:10
(anonymous) @ PreviewWeb.js:10
(anonymous) @ PreviewWeb.js:10
selectSpecifiedStory @ PreviewWeb.js:348
(anonymous) @ PreviewWeb.js:288
(anonymous) @ index.js:217
_runResolutions @ index.js:214
then @ index.js:67
initializeWithStoryIndex @ PreviewWeb.js:281
(anonymous) @ PreviewWeb.js:178
(anonymous) @ index.js:217
_runResolutions @ index.js:214
then @ index.js:67
initializeWithProjectAnnotations @ PreviewWeb.js:177
(anonymous) @ PreviewWeb.js:119
(anonymous) @ index.js:217
_runResolutions @ index.js:214
then @ index.js:67
initialize @ PreviewWeb.js:118
configure @ start.js:148
configure @ index.js:21
(anonymous) @ generated-stories-entry.js:6
./generated-stories-entry.js @ generated-stories-entry.js:6
__webpack_require__ @ bootstrap:853
fn @ bootstrap:150
0 @ storybook-init-framework-entry.js:1
__webpack_require__ @ bootstrap:853
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.iframe.bundle.js:1
Show 7 more frames
index.js:56 Error: Couldn't find story matching 'icongroup--default'.
- Are you sure a story with that id exists?
- Please check your stories field of your main.js config.
- Also check the browser console and terminal for error messages.
at PreviewWeb._callee3$ (PreviewWeb.js:322:1)
at tryCatch (runtime.js:63:1)
at Generator.invoke [as _invoke] (runtime.js:294:1)
at Generator.next (runtime.js:119:1)
at asyncGeneratorStep (PreviewWeb.js:8:1)
at _next (PreviewWeb.js:10:1)
at PreviewWeb.js:10:1
at new Promise (<anonymous>)
at PreviewWeb.<anonymous> (PreviewWeb.js:10:1)
at PreviewWeb.selectSpecifiedStory (PreviewWeb.js:348:1)