nuxt-modules / storybook

Storybook integration with Nuxt.
https://storybook.nuxtjs.org
401 stars 91 forks source link

Problems when running with `/pages` directory #761

Open obulat opened 3 weeks ago

obulat commented 3 weeks ago

When the Nuxt app has a non-empty pages directory, you get the following errors in the console:

vue-router.mjs:35 [Vue Router warn]: No match found for location with path "/iframe.html?id=features-custom-components--custom-template&viewMode=story"
warn @ vue-router.mjs:35
nuxt.js:122 [nuxt] error caught during app initialization Error: Page not found: /iframe.html?id=features-custom-components--custom-template&viewMode=story
    at createError (index.mjs:78:15)
    at router.js:109:29
    at fn (nuxt.js:214:44)
    at Object.runWithContext (runtime-core.esm-bundler.js:2696:18)
    at callWithNuxt (nuxt.js:220:24)
    at nuxt.js:37:41
    at EffectScope.run (reactivity.esm-bundler.js:43:16)
    at Object.runWithContext (nuxt.js:37:31)
    at router.js:109:25
    at vue-router.mjs:3432:52

To reproduce, run example:showcase:dev and go to "http://localhost:6006/?path=/story/features-custom-components--custom-template". You should see this error message displayed twice in the console.

Nuxt only adds the app/router plugin when there are no pages:

https://github.com/nuxt/nuxt/blob/3b907c1c6aa623e88125d731fd267e6a9a89abba/packages/nuxt/src/pages/module.ts#L121-L122

tobiasdiez commented 2 weeks ago

@chakAs3 Could you please explain how the custom router setup in the storybook addon works?

In particular, why do we need to: