-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
12 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@storybook-vue/nuxt", | ||
"version": "0.2.3-alpha.6", | ||
"version": "0.2.3-alpha.7", | ||
"packageManager": "[email protected]", | ||
"description": "Storybook for Nuxt and Vite: Develop Vue3 components in isolation with Hot Reloading.", | ||
"license": "MIT", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<template> | ||
<div> | ||
<MyNuxtImage /> | ||
|
||
<NuxtWelcome msg="Hello from Nuxt" /> | ||
<NuxtPage /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,6 @@ | ||
// import { useStorybook } from './runtime/composables/storybook' | ||
|
||
import { applyPlugins, createNuxtApp } from 'nuxt/app' | ||
import { nextTick } from 'vue' | ||
import { getContext } from 'unctx' | ||
|
||
// These files must be imported first as they have side effects: | ||
// 1. (we set __webpack_public_path via this import, if using webpack builder) | ||
import '#build/paths.mjs' | ||
|
||
// 2. we set globalThis.$fetch via this import | ||
import '#build/fetch.mjs' | ||
|
||
// @ts-expect-error virtual file | ||
import plugins from '#build/plugins' | ||
|
||
import '#build/css' | ||
|
||
const globalWindow = window as any | ||
|
||
// entry() | ||
const logger = console | ||
|
||
async function applyNuxtPlugins(vueApp: any, storyContext: any) { | ||
const nuxt = createNuxtApp({ vueApp, globalName: `nuxt-${storyContext.id}` }) | ||
getContext('nuxt-app').set(nuxt, true) | ||
logger.log('🔌 🔌 🔌 [storybook-nuxt-plugin] setup ', { nuxtApp: nuxt }) | ||
async function handleVueError(err: any) { | ||
await nuxt.callHook('app:error', err) | ||
nuxt.payload.error = (nuxt.payload.error || err) as any | ||
} | ||
|
||
vueApp.config.errorHandler = handleVueError | ||
|
||
try { | ||
await applyPlugins(nuxt, plugins) | ||
} | ||
catch (err) { | ||
handleVueError(err) | ||
} | ||
try { | ||
await nuxt.hooks.callHook('app:created', vueApp) | ||
await nuxt.hooks.callHook('app:beforeMount', vueApp) | ||
setTimeout(async () => { | ||
await nuxt.hooks.callHook('app:mounted', vueApp) | ||
await nextTick() | ||
}, 10) | ||
} | ||
catch (e) { | ||
// consola.error('Vue Error in plugins ', e) | ||
} | ||
|
||
return nuxt | ||
async function initNuxt() { | ||
const { useStorybook } = await import('./runtime/composables/storybook') | ||
useStorybook() | ||
} | ||
globalWindow.PLUGINS_SETUP_FUNCTIONS ||= new Set() | ||
globalWindow.PLUGINS_SETUP_FUNCTIONS.add(applyNuxtPlugins) | ||
|
||
export default applyNuxtPlugins | ||
initNuxt() | ||
export default initNuxt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters