2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Storybook(vue)】ERROR in ./stories/button.stories.js Module not found: Error: Can't resolve '@/components/atoms/Button.vue' in '/webapp/stories' のエラー解決策

2
Posted at

問題

vueのStorybook上で、@(アットマーク)を使用したcomponentのインポートができない。

ERROR in ./stories/button.stories.js
Module not found: Error: Can't resolve '@/components/atoms/Button.vue' in '/webapp/stories'

解決策

storybookの webpack.config.js に記述

webpack.config.js
  config.resolve.alias['@'] = rootPath

これでいけるかと思ったが、dynamicImportの構文サポートは現在利用できませんエラーが出る。

Support for the experimental syntax 'dynamicImport' isn't currently enabled

そこで、.babelrcに以下のプラグインを記述する。

.babelrc
{
  "plugins": ["@babel/plugin-syntax-dynamic-import"]
}

これでStorybook上で@を用いたコンポーネントのインポートができるようになる。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?