storybook-nuxt
storybook-nuxt copied to clipboard
Add optional dev flag to Nuxt module
~~In monorepo setup, for example, I'll have only one sandbox "app" (Nuxt calls this a "playground") which will run Storybook in dev mode. If I have many other apps, I don't want to actually run Storybook dev instances per each app (playground pulls stories from all the other apps.)~~
~~However, in production deployments, I do want a static storybook build per each app, so I still want to install Storybook Nuxt on all apps, just not run all apps in dev mode.~~
~~Therefore, it should be optional to auto-install and auto-add the module to an app. The proposal is to make the cli respect a new flag called --module
:~~
~~pnpm dlx storybook-nuxt@latest init --module
~~
Another solution could be to always install, but use options in Nuxt config for the module, like:
export default defineNuxtConfig({
modules: [
'@storybook-vue/nuxt-storybook'
],
storybook: {
// Default to false, as most apps should only run production builds and its "expensive" to run dev servers
dev: true
}
})
I think I actually like the second proposal better, and would be extremely simple to make a PR for.
In Nuxt module:
export default defineNuxtModule<ModuleOptions>({
meta: {
name: 'storybook-nuxt',
configKey: 'storybook'
},
defaults: {
dev: false
},
async setup (options, nuxt) {
....
if(nuxt.options.dev && options.dev) {
// Start Storybook dev server
}
}
}