Closed atif0075 closed 5 months ago
main.js
import { createApp } from "vue"; import "./styles.css"; import App from "./App.vue"; const app = createApp(App); import { ViteSSG } from 'vite-ssg'; // Install all modules under `modules/` const moduleFiles = import.meta.globEager("./modules/*.js"); Object.values(moduleFiles).forEach((module) => { if (module && module.install) { app.use(module); } else if (module.default && module.default.install) { app.use(module.default); } }); app.mount("#app");
./modules/router.js
import router from "../router/routes"; export default { install: (app) => { app.use(router); }, };
Router Config with unplugin-vue-router and vite-plugin-vue-layouts routes.js
import { createRouter, createWebHistory } from "vue-router/auto"; import { setupLayouts } from "virtual:generated-layouts"; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), extendRoutes: (routes) => setupLayouts(routes), }); export default router;
Hi @atif0075,
What are you trying to achieve here? A default vite installation seem to achieve exactly what you describe. https://github.com/antfu/vite-ssg?tab=readme-ov-file#custom-routes-to-render
How can I add SSG to my home "/" route while other routes remain the same?
main.js
./modules/router.js
Router Config with unplugin-vue-router and vite-plugin-vue-layouts routes.js
How can I implement the SSG to "/" without disturbing the other, is it possible or not?