first commit
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
import { createSSRApp, createApp } from 'vue';
|
||||
import App from './App.vue';
|
||||
import { createAppRouter } from './router';
|
||||
|
||||
// 서버(사전 렌더링)와 브라우저가 공유하는 앱 팩토리
|
||||
export function createPickApp({ ssr = false } = {}) {
|
||||
const isBrowser = !ssr && typeof window !== 'undefined';
|
||||
// 브라우저에서 #app 내에 사전 렌더링된 실제 DOM 요소가 있을 때만 hydrate(createSSRApp), 없으면 클린 마운트(createApp)
|
||||
const hasSsrMarkup = isBrowser && !!document.querySelector('#app')?.firstElementChild;
|
||||
const shouldUseSSR = ssr || hasSsrMarkup;
|
||||
|
||||
const app = shouldUseSSR ? createSSRApp(App) : createApp(App);
|
||||
const router = createAppRouter({ ssr });
|
||||
app.use(router);
|
||||
return { app, router };
|
||||
}
|
||||
Reference in New Issue
Block a user