Skip to content

imports for storybook stories #365

@blowsie

Description

@blowsie

Should storybook stories work by just adding the files to the include option in the config?

I tried the following, and whilst I can see the components.d.ts file correctly, and unplugin-vue-components is working correctly from within the .vue components, I'm not getting any auto imports working from within my stories themselves.

Please see example below

PGrid.stories.ts

import type { Meta, Story } from '@storybook/vue3'
import PGrid from './PGrid.vue'

export default {
  title: 'Portal/Grid',
  component: PGrid,
  args: {
    items: [{
        id: 1
        }]
  },
} as Meta

const Template: Story<Props> = args => ({
  components: { }, // <== note im not adding PGrid
  setup() {
    return {
      ...args,
    }
  },
  template: `
    <PGrid 
        :items="items"
    />
  `,// <== not working, PGrid not imported / loaded
})

webpack.config.js

const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
module.exports = ({config, mode}) => {
  config.plugins.push(AutoImport({
    imports: [
      'vue',
      'vue-router',
      'vue-i18n',
      'vue/macros',
      '@vueuse/head',
      '@vueuse/core',
    ],
    dts: '.storybook/auto-imports.d.ts',
  }))
  config.plugins.push(Components({
    dirs: ['src/components', '.storybook/common'],
    extensions: ['vue'],
    include: [/\.vue$/, /\.vue\?vue/, /\.stories\.js$/, /\.stories\.ts$/],
    dts: '.storybook/components.d.ts',
  }))
  return config
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy