Last active
November 20, 2022 17:45
-
-
Save Maxim-Kolmogorov/a3bd43eba5bb71c51c269dd99e1b516d to your computer and use it in GitHub Desktop.
Laravel 9 + Vite + Vue.js + SSR = example, part 7
This file contains hidden or 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
| /* global var process from node */ | |
| import { createSSRApp } from 'vue' | |
| import { renderToString } from 'vue/server-renderer' | |
| import router from './router.js'; | |
| import App from './App.vue'; | |
| (async function main() { | |
| const requestUrl = process.argv[2] || '/'; | |
| const app = createSSRApp(App); | |
| app.use(router); | |
| // Пушим путь в router, если перешли на компонент напрямую | |
| await router.push(requestUrl); | |
| await router.isReady(); | |
| const html = await renderToString(app); | |
| process.stdout.write(html); | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment