Skip to content

Pass Vue compiler options in nuxt.config to the Storybook Vue plugin #978

Description

@benedictleejh

Environment

NA

Reproduction

NA

Describe the bug

Currently, any options set in vue.compilerOptions in nuxt.config are not passed to the Vue plugin during the Storybook setup (https://github.com/nuxt-modules/storybook/blob/main/packages/storybook-addon/src/preset.ts#L176-L184). This can result in a difference in rendering when rendering in Storybook and when rendering in dev server/production, reducing the effectiveness of Nuxt Storybook as a testing environment.

Additional context

Not passing the compiler options to the plugin may also cause things to break in Storybook. For example, if someone has set compilerOptions.delimiters, they would be using different delimiters than the default, and the Storybook Vue renderer would not know that, potentially rendering a plain string when it should be interpolated. And it would work perfectly normally in dev and production mode, creating more confusion as to why it wouldn't work only in Storybook.

I have attempted to set these options in .storybook/{main,preview}.ts via the setup function imported from @nuxtjs/storybook, but Vite just ends up throwing ERR_PACKAGE_PATH_NOT_EXPORTED if I try to do it in main.ts, and a Importing directly from module entry-point is not allowed if I do it in preview.ts. I ended up using viteFinal inside Storybook config in main.ts to replace the existing plugin with one that has the necessary compiler options passed to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions