vuetify-nuxt-module: Unable to run with storybook

My setup:

  • Operating System: Darwin
  • Node Version: v20.5.0
  • Nuxt Version: 3.9.0
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: pnpm@8.10.5
  • Builder: -
  • User Config: modules, i18n, devtools
  • Runtime Modules: @nuxtjs/i18n@8.0.0, vuetify-nuxt-module@0.8.0
  • Build Modules: -

Reproduction

https://github.com/AndreyYolkin/storybook-vuetify-issue

Description

Thank you for your titanic work on building this module. I’ve tried to add storybook into my project, but for some reasons vuetify works in dev mode and have some problems inside storybook. Please follow the readme to get the error in reproduction.

Additional details

  1. There is a working example with another nuxt-vuetify module (not maintained anymore): https://github.com/storybook-vue/storybook-nuxt-starter
  2. I’ve also left the comment in storybook-nuxt repo https://github.com/storybook-vue/storybook-nuxt/issues/42#issuecomment-1877067150

About this issue

  • Original URL
  • State: open
  • Created 6 months ago
  • Comments: 45 (25 by maintainers)

Most upvoted comments

Vuetify components seems to be loaded without defaults, I’m checking if there is a problem with vuetify post plugin in this module and storybook.

FYI: I don’t see any page using any Vuetify component in https://github.com/storybook-vue/storybook-nuxt-starter

I have released @storybook-vue/nuxt 0.2.1 with patch fixing this issue,.

if it did not work for you please create a repro repo for me. i will check it out

Will try tomorrow, not sure, because it was released even before vuetify 3.4 and nuxt 3.7.

Sorry, another timezone

Tried also using defineAsyncComponent, no luck, same error (removing enforce: 'post' patch):

const Vuetify = defineAsyncComponent({
  loader: () => import('~/components/vuetify/index.vue').then(m => m.default ?? m),
  loadingComponent: () => h('div', 'loading...'),
  onError(error, retry, fail, attempts) {
    console.error('Vuetify::error', error)
  },
})
const VuetifyWithImports = defineAsyncComponent({
  loader: () => import('~/components/vuetify/withImports.vue').then(m => m.default ?? m),
  loadingComponent: () => h('div', 'loading...'),
  onError(error, retry, fail, attempts) {
    console.error('VuetifyWithImports::error', error)
  },
})

I’m going to update the repo to ^7.6.7 :fingers_crossed:

I’ve achieved the same result rn with this: image

ok, found the problem: https://github.com/storybook-vue/storybook-nuxt/blob/main/packages/storybook-nuxt/src/preset.ts#L95C26-L97

calling with raw vue file since it is moving all plugins before vue

In build:

imagen

it is being called in the build, it works, the imports are there, but storybook calling again with raw vue file:

imagen

I suppose it also happens because nuxt plugin runs too late

No, it seems vuetify vite plugin missing from vite plugins.

I don’t know why applyNuxtPlugins are called after rendering the pages, I just added a breakpoint in the nuxtjs/i18n warning, storybook should review Nuxt 3 integration logic.

This module enables treeshaking feature via vuetify vite plugin (there is no way to use all components, you need to add them to vuetify.vuetifyOptions.components in the nuxt configuration or vuetify config file), the deprecated nuxt module by default not enabling that feature IIRC (maybe also a problem with nuxt vuetify sequential post plugin, i18n is installed and configured in the app).