|
1 | 1 | import path from 'path' |
2 | 2 | import fs from 'fs' |
3 | 3 | import { spawn, type ChildProcess } from 'child_process' |
4 | | - |
5 | 4 | import { defineNuxtModule, createResolver, resolveFiles, addComponent, addImportsDir, extendPages } from '@nuxt/kit' |
6 | 5 | import type { NuxtPage } from '@nuxt/schema' |
7 | 6 | import { joinURL, withoutLeadingSlash, withoutTrailingSlash } from 'ufo' |
@@ -55,22 +54,29 @@ export default defineNuxtModule<NuxtStoriesOptions>({ |
55 | 54 | mode: 'all', |
56 | 55 | framePort: 3000, |
57 | 56 | }, |
58 | | - moduleDependencies: { |
59 | | - '@primevue/nuxt-module': { |
60 | | - version: '^4', |
61 | | - defaults: { |
62 | | - autoImport: false, |
63 | | - components: { |
64 | | - prefix: 'pv', |
65 | | - include: ['Tree', 'Button', 'InputText', 'Splitter', 'SplitterPanel', 'Toolbar', 'Menu'], |
66 | | - }, |
67 | | - options: { |
68 | | - theme: { |
69 | | - preset: Aura, |
| 57 | + moduleDependencies(nuxt) { |
| 58 | + const mode = |
| 59 | + (process.env.NUXT_STORIES_MODE as string | undefined) || |
| 60 | + (nuxt.options as unknown as { stories?: { mode?: string } }).stories?.mode || |
| 61 | + 'all' |
| 62 | + if (mode === 'frame') return {} |
| 63 | + return { |
| 64 | + '@primevue/nuxt-module': { |
| 65 | + version: '^4', |
| 66 | + defaults: { |
| 67 | + autoImport: false, |
| 68 | + components: { |
| 69 | + prefix: 'pv', |
| 70 | + include: ['Tree', 'Button', 'InputText', 'Splitter', 'SplitterPanel', 'Toolbar', 'Menu'], |
| 71 | + }, |
| 72 | + options: { |
| 73 | + theme: { |
| 74 | + preset: Aura, |
| 75 | + }, |
70 | 76 | }, |
71 | 77 | }, |
72 | 78 | }, |
73 | | - }, |
| 79 | + } |
74 | 80 | }, |
75 | 81 | async setup(options, nuxt) { |
76 | 82 | if (!options.enabled) return |
@@ -113,16 +119,6 @@ export default defineNuxtModule<NuxtStoriesOptions>({ |
113 | 119 | ? `http://localhost:${options.framePort ?? 3000}` |
114 | 120 | : undefined |
115 | 121 |
|
116 | | - // // Alias primevue to the module's own node_modules so runtime components |
117 | | - // // can import from 'primevue/...' without requiring the consuming app to install it. |
118 | | - // const primeVueDir = path.dirname( |
119 | | - // resolveModule('primevue/package.json', { paths: [resolver.resolve('.')] }), |
120 | | - // ) |
121 | | - // nuxt.options.alias['primevue'] = primeVueDir |
122 | | - |
123 | | - // // Register the PrimeVue shell plugin (unstyled, no CSS contamination) |
124 | | - // addPlugin(resolver.resolve('./runtime/plugins/primevue')) |
125 | | - |
126 | 122 | // Expose base paths so runtime composables can compute URLs dynamically |
127 | 123 | nuxt.options.runtimeConfig.public.nuxtStories = { |
128 | 124 | routeBasePath, |
|
0 commit comments