nuxt-modules / storybook

Storybook integration with Nuxt.
https://storybook.nuxtjs.org
378 stars 82 forks source link

Static build #597

Closed NicklasDegnebolig closed 2 weeks ago

NicklasDegnebolig commented 1 month ago

Issue Description:

I'm encountering some challenges while integrating Storybook and Chromatic into my Nuxt 3 project. While everything runs smoothly in development mode, I'm facing difficulties when attempting to build Storybook for static files. It appears that some Vue/Nuxt components are not being bundled correctly, and crucial files like env.mjs are missing from the build.

Current Behavior:

When running Storybook in development mode, all components, including dynamic ones utilizing features like nuxt useRuntimeConfig, nuxt/vue components, composables, useAppConfig, function as expected. However, upon generating static files using the Storybook build function, certain Vue/Nuxt components are not properly bundled. Additionally, the absence of the env.mjs file suggests potential configuration or build process issues. Dynamic components seem particularly affected, as evidenced by discrepancies in their behavior post-build.

Steps to Reproduce:

Set up a Nuxt 3 project with Storybook Develop and test Vue/Nuxt components in Storybook's development mode. Execute the Storybook build command to generate static files. Observe the inconsistencies in bundled components and missing files.

reprodcutin repositery: https://github.com/NicklasDegnebolig/nuxt3-storybook-sandbox

Expected Behavior:

Storybook should accurately bundle all Vue/Nuxt components, including dynamic ones, during the build process. The presence of essential files like env.mjs should be ensured to maintain functionality across different environments. Additional Information:

I've documented my observations and concerns in more detail on the Nuxt Modules GitHub repository here. I'm open to contributing to the module to address these issues and ensure stable support for Nuxt 3 projects. However, I require guidance on how to proceed effectively.

peteromano commented 3 weeks ago

Yea I've never gotten the static build to work for storybook nuxt. It (along with testing) is arguably more important than dev mode.

tobiasdiez commented 2 weeks ago

Static builds are now generally working, as we test by deploying a few example applications to chromatic.

There are still a few issues with certain modules or nuxt features, but these are tracked elsewhere already (see also https://github.com/nuxt-modules/storybook/pulls?q=is%3Apr+is%3Aopen+label%3A%22status%3A+needs+info%2Fwork%22). If you encounter any other problems, please open a new issue.