Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low Priority: Scan stories from Nuxt layers #40

Open
peteromano opened this issue Aug 16, 2023 · 1 comment
Open

Low Priority: Scan stories from Nuxt layers #40

peteromano opened this issue Aug 16, 2023 · 1 comment

Comments

@peteromano
Copy link

peteromano commented Aug 16, 2023

With Nuxt's layer/extends mechanism, my idea is that folks could extend from abstract layers or apps, and the only "main" app could use Storybook to compile all components from the hierarchy into a only single SB instance.

I have a separate Nuxt module writing out the layer paths (i.e., on nuxt prepare), then use it in SB main.

Feels like storybook-vue/nuxt could easily include these paths by default instead of the user defining it, although its debatable if it should.. maybe it would be good to just write out the layers template for users to use:

// some-module/src/module.ts

    addTemplate({
      filename: 'layers.mjs',
      write: true,
      getContents () {
        // @ts-ignore
        return `export default [${nuxt.options._layers.map(({ cwd }) =>
  `
  '${cwd}'`).join(',')}\n]`
      }
    })
// .storybook/main.ts

import layers from '../.nuxt/layers'     <---- Ugly

const config: StorybookConfig = {
  stories: layers.map(layer => [
    `${layer}/**/*.mdx`,
    `${layer}/**/*.stories.@(js|jsx|ts|tsx)`
  ]).flat()),
  ...
}
@chakAs3
Copy link
Contributor

chakAs3 commented Aug 26, 2023

@peteromano

Feels like storybook-vue/nuxt could easily include these paths by default instead of the user defining it

yes good point, it is in my pipeline already. we will discuss it once i start working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants