Skip to content

Autoimports is not working in tesiting components

Open

Description

Hi!
This my first issue :)

I have a problem with integration storybook 8+ and nuxt 3.11+, auto imports is not working in testing components.

Example TestingComponent.vue:

import { ref } from 'vue';
import VInput from '@/components/VInput';

If component are using any instrument vue(ref, reactive, ..) or any components/composables/utils without precise import, then storybook has reject, requiring to add an import.

My step:

  1. Integrate storybook module https://nuxt.com/modules/storybook and install npm i storybook-addon-nuxt
    1.1 Integrate storybook without module - there are no differences
  2. Create config

My config .storybook/main.ts:


import { StorybookConfig } from "@storybook/vue3-vite";
import vue from "@vitejs/plugin-vue";
import pathNode from "path";

const SOURCE = "../";

/** Create path*/
const createAliasPath = (path?: string) => {
  const correctPath = path ? `${SOURCE}/${path}` : SOURCE;
  return pathNode.resolve(__dirname, correctPath);
};

const config: StorybookConfig = {
  stories: ["../components/SharedLogo/SharedLogo.stories.@(ts|jsx|js|tsx)"],
  framework: "@storybook/vue3-vite",
  addons: [
    "storybook-addon-nuxt",
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-interactions",
    "@chromatic-com/storybook"
  ],
  typescript: {
    check: true
  },
  async viteFinal(config) {
    const { mergeConfig } = await import("vite");

    const mergeConfigs = mergeConfig(config, {
      plugins: [vue()],
      resolve: {
        alias: {
          ...config.resolve?.alias,
          "~": createAliasPath()
        }
      }
    });

    return mergeConfigs;
  }
};

export default config;

My version nuxt: 3.11.2.
storybook-addon-nuxt 1.3.3(last) and storybook 8.11(last) have warn about their version

Screenshot storybook page
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    status: help wantedGood idea, but the core developers will not work on it at the momentGood idea, but the core developers will not work on it at the momenttype: bugSomething isn't workingSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions