我正在尝试将StoryBook与Angular6一起使用。我有一个基本的hello world storybook应用程序。我的应用程序使用本地npm模块,并且我的组件成功引用了它,例如
import { MySdkSettings } from 'test-sdk-lib';
我的package.json像
那样导入"test-sdk-lib": "file:externals/js-test-vc-sdk/dist/test-sdk-lib",
但是,这在故事书中失败,因为它引发了以下错误:
index.js:19 TypeError: Cannot set property 'test-sdk-lib' of undefined
at push../externals/js-test-vc-sdk/dist/test-sdk-lib/bundles/test-sdk-lib.umd.js (config.js:8)
at Module../externals/js-test-vc-sdk/dist/test-sdk-lib/bundles/test-sdk-lib.umd.js (config.js:8)
at __webpack_require__ (bootstrap:781)
at fn (bootstrap:149)
at Object../src/app/components/my-button/my-button.component.ts (my-button.component.ts:2)
at __webpack_require__ (bootstrap:781)
at fn (bootstrap:149)
at Object.<anonymous> (index.stories.ts:5)
at Object../src/stories/index.stories.ts (index.stories.ts:21)
at __webpack_require__ (bootstrap:781)
StoryBook无法引用它,除非我将导入语句更改为import { MySdkSettings } from 'externals/js-test-vc-sdk/dist/test-sdk-lib';
到目前为止,我已经尝试在.storybook/tsconfig.json
中设置editorOptions路径,并在.storybook/webpack.config.js
中尝试了resolve.alias,但是编译器似乎并没有选择该路径。