8000 feat(nuxt): make `app.rootId` optional by DamianGlowala Β· Pull Request #22528 Β· nuxt/nuxt Β· GitHub
[go: up one dir, main page]

Skip to content

feat(nuxt): make app.rootId optional #22528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: mount Vue app to imported vueAppRootContainer
  • Loading branch information
DamianGlowala committed Aug 9, 2023
commit 61894fc5e347d83d379c835b1bf6a6e5f8a4a2dc
4 changes: 2 additions & 2 deletions packages/nuxt/src/app/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import plugins from '#build/plugins'
// @ts-expect-error virtual file
import RootComponent from '#build/root-component.mjs'
// @ts-expect-error virtual file
import { appRootId, appRootTag } from '#build/nuxt.config.mjs'
import { vueAppRootContainer } from '#build/nuxt.config.mjs'

if (!globalThis.$fetch) {
globalThis.$fetch = $fetch.create({
Expand Down Expand Up @@ -75,7 +75,7 @@ if (import.meta.client) {
try {
await nuxt.hooks.callHook('app:created', vueApp)
await nuxt.hooks.callHook('app:beforeMount', vueApp)
vueApp.mount(appRootId ? `#${appRootId}` : `body > ${appRootTag}`)
vueApp.mount(vueAppRootContainer)
await nuxt.hooks.callHook('app:mounted', vueApp)
await nextTick()
} catch (err) {
Expand Down
3 changes: 2 additions & 1 deletion packages/nuxt/src/core/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ export const nuxtConfigTemplate = {
`export const componentIslands = ${!!ctx.nuxt.options.experimental.componentIslands}`,
`export const remoteComponentIslands = ${ctx.nuxt.options.experimental.componentIslands === 'local+remote'}`,
`export const devPagesDir = ${ctx.nuxt.options.dev ? JSON.stringify(ctx.nuxt.options.dir.pages) : 'null'}`,
`export const devRootDir = ${ctx.nuxt.options.dev ? JSON.stringify(ctx.nuxt.options.rootDir) : 'null'}`
`export const devRootDir = ${ctx.nuxt.options.dev ? JSON.stringify(ctx.nuxt.options.rootDir) : 'null'}`,
`export const vueAppRootContainer = ${ctx.nuxt.options.app.rootId ? `#${ctx.nuxt.options.app.rootId}` : `body > ${ctx.nuxt.options.app.rootTag}`}`
].join('\n\n')
}
}
Expand Down
0