Skip to content

Commit

Permalink
fix resolving preset on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
chakAs3 committed Oct 3, 2023
1 parent d6ddde0 commit 458f34a
Show file tree
Hide file tree
Showing 4 changed files with 670 additions and 1,079 deletions.
3 changes: 3 additions & 0 deletions packages/storybook-nuxt/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export default defineBuildConfig({
dependencies: [
'vue-router',
'vue',
'@storybook/vue3',
'@storybook/builder-vite',
'@storybook/vue3-vite',
],
externals: [
'nuxt',
Expand Down
6 changes: 3 additions & 3 deletions packages/storybook-nuxt/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook-vue/nuxt",
"version": "0.1.4",
"version": "0.1.4-alpha.0",
"packageManager": "[email protected]",
"description": "Storybook for Nuxt and Vite: Develop Vue3 components in isolation with Hot Reloading.",
"license": "MIT",
Expand Down Expand Up @@ -71,8 +71,8 @@
"@nuxt/schema": "^3.7.4",
"@nuxt/vite-builder": "^3.7.4",
"@storybook/builder-vite": "7.4.4",
"@storybook/vue3": "7.4.4",
"@storybook/vue3-vite": "7.4.4",
"@storybook/vue3": "npm:@storybook-vue/[email protected]",
"@storybook/vue3-vite": "npm:@storybook-vue/[email protected]",
"autoprefixer": "^10.4.15",
"postcss": "^8.4.27",
"postcss-import": "^15.1.0",
Expand Down
12 changes: 5 additions & 7 deletions packages/storybook-nuxt/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,19 @@ function extendComponents(nuxt: Nuxt) {
* */

async function extendComposables(nuxt: Nuxt) {
const { addImportsSources } = await import(require.resolve('@nuxt/kit'))
const { addImportsSources } = await import('@nuxt/kit')
nuxt.options.build.transpile.push(composablesDir)
addImportsSources({ imports: ['useRouter'], from: join(composablesDir, 'router') })
}

async function defineNuxtConfig(baseConfig: Record<string, any>) {
const { loadNuxt, buildNuxt, addPlugin, extendPages } = await import(require.resolve('@nuxt/kit'))
const { loadNuxt, buildNuxt, addPlugin, extendPages } = await import('@nuxt/kit')
nuxt = await loadNuxt({
rootDir: baseConfig.root,
ready: false,
dev: false,
overrides: {
ssr: false,
target: 'static',
build: {
ssr: false,
},
},
})

Expand Down Expand Up @@ -129,7 +125,9 @@ export const viteFinal: StorybookConfig['viteFinal'] = async (
options: any,
) => {
const getStorybookViteConfig = async (c: Record<string, any>, o: any) => {
const { viteFinal: ViteFile } = await import(require.resolve(join('@storybook/vue3-vite', 'preset')))
const { viteFinal: ViteFile } = await import(join('@storybook/vue3-vite', 'preset'))
if (!ViteFile)
throw new Error('ViteFile not found')
return ViteFile(c, o)
}
const nuxtConfig = await defineNuxtConfig(await getStorybookViteConfig(config, options))
Expand Down
Loading

0 comments on commit 458f34a

Please sign in to comment.