Skip to content

Commit ac15e16

Browse files
committed
build: storybook-static,still have nuxt inst issue
1 parent 8f4da17 commit ac15e16

File tree

7 files changed

+20
-11
lines changed

7 files changed

+20
-11
lines changed

packages/storybook-nuxt-cli/src/add-module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import { existsSync } from 'node:fs'
22
import fsp from 'node:fs/promises'
33
import { relative } from 'node:path'
44
import { cwd } from 'node:process'
5-
import { consola } from 'consola'
5+
6+
// import { consola } from 'consola'
67
import c from 'picocolors'
78
import { parseModule } from 'magicast'
89
import { diffLines } from 'diff'
910
import path, { join } from 'pathe'
1011

12+
const consola = console
13+
1114
export async function addModuleToNuxtConfigFile(moduleName, cwd) {
1215
const nuxtConfig = findNuxtConfig(cwd)
1316
if (!nuxtConfig) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<template>
2-
<NuxtImg src="https://raw.githubusercontent.com/nuxt/nuxt/HEAD/.github/assets/banner.png" />
2+
<NuxtImg src="https://github-production-user-asset-6210df.s3.amazonaws.com/904724/267021354-0396b16c-be9b-4b0d-83b5-5e35dd8298df.png" />
33
</template>

packages/storybook-nuxt/playground/pages/about.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ defineProps({
66

77
<template>
88
<div>
9-
About Storybook Nuxt Playground
9+
About Storybook Nuxt Playground with Nuxt Image
1010
</div>
1111
<div>
1212
{{ msg }}
1313
</div>
14+
Nuxt Image
15+
<MyNuxtImage />
1416
</template>

packages/storybook-nuxt/playground/pages/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ defineProps({
77
<template>
88
<div>
99
Home Storybook
10+
Nuxt Image
11+
<MyNuxtImage />
1012
</div>
1113
<div>
1214
{{ msg }}

packages/storybook-nuxt/src/preset.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ async function extendComposables(nuxt: Nuxt) {
4747

4848
async function defineNuxtConfig(baseConfig: Record<string, any>) {
4949
const { loadNuxt, buildNuxt, addPlugin, extendPages } = await import('@nuxt/kit')
50+
5051
nuxt = await loadNuxt({
5152
rootDir: baseConfig.root,
5253
ready: false,
53-
dev: false,
54+
dev: process.env.NODE_ENV !== 'production',
55+
5456
overrides: {
5557
ssr: false,
5658
},
@@ -137,7 +139,7 @@ export const viteFinal: StorybookConfig['viteFinal'] = async (
137139
const nuxtConfig = await defineNuxtConfig(await getStorybookViteConfig(config, options))
138140

139141
return mergeConfig(nuxtConfig.viteConfig, {
140-
build: { rollupOptions: { external: ['vue', 'vue-demi'] } },
142+
build: { rollupOptions: { external: process.env.NODE_ENV === 'production' ? [] : ['vue', 'vue-demi'] } },
141143
define: {
142144
__NUXT__: JSON.stringify({ config: nuxtConfig.nuxt.options.runtimeConfig }),
143145
},
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import consola from 'consola'
2-
31
const vueAppRootContainer = document.createElement('div')
42
vueAppRootContainer.id = '__nuxt'
53
vueAppRootContainer.setAttribute('hidden', 'true')
@@ -8,12 +6,12 @@ document.body.appendChild(vueAppRootContainer)
86
async function nuxtAppEntry() {
97
const nuxtApp = () => import(('#app/entry')).then(m => m.default).catch(() => {})
108
// i
11-
const vueAppPromise = nuxtApp().catch((error) => {
12-
consola.error('Error while mounting app:', error)
9+
const vueAppPromise = nuxtApp().catch((_error) => {
10+
// consola.error('Error while mounting app:', error)
1311
})
1412
return vueAppPromise
1513
}
1614

1715
nuxtAppEntry().then((app) => {
18-
consola.info('nuxtAppEntry done', app)
16+
// consola.info('nuxtAppEntry done', app)
1917
})

packages/storybook-nuxt/src/runtime/plugins/storybook.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createNuxtApp, defineNuxtPlugin } from 'nuxt/app'
22
import { getContext } from 'unctx'
3-
import logger from 'consola'
3+
4+
// import logger from 'consola'
45

56
import type { App } from 'vue'
67
import { createRouter, createWebHistory } from 'vue-router'
@@ -11,6 +12,7 @@ import plugins from '#build/plugins'
1112
import '#build/css'
1213

1314
const globalWindow = window as any
15+
const logger = console
1416

1517
export default defineNuxtPlugin({
1618
name: 'storybook-nuxt-plugin',

0 commit comments

Comments
 (0)