Skip to content

Absolute Imports in Storybook Vite #411

Answered by IanVS
jaroslav-kavalec asked this question in Q&A
Discussion options

You must be logged in to vote

It looks like you need to add the tsconfigpaths plugin to storybook as well. We don't automatically use your vite.config.js, because there is custom config that the builder needs to do, and we can't assume every config is the same between the app and stories.

You should be able to do something like:

const {mergeConfig} = require('vite');
const tsconfigPaths = require('vite-tsconfig-paths');

module.exports = {
  "stories": [
    "../src/**/*.stories.mdx",
    "../src/**/*.stories.@(js|jsx|ts|tsx)"
  ],
  "addons": [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-interactions"
  ],
  "framework": "@storybook/react",
  "core": {
    "builder": "@story…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@jaroslav-kavalec
Comment options

Answer selected by jaroslav-kavalec
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants