vue-cli-plugin-prerender-spa
vue-cli-plugin-prerender-spa copied to clipboard
Missing index.html when redirecting routes with vi18n
Describe the bug
Index.html in the dist folder. I have vue-i18n for localization and redirecting the /
to /:lang/
as per the vi18n documentation
router/index.js
/* eslint-disable no-unused-vars */
import Vue from "vue";
import VueRouter from "vue-router";
const Home = () => import("../views/Home.vue");
const Services = () => import("../views/Services.vue");
const ComingSoon = () => import("../views/ComingSoon.vue");
const NotFound = () => import("../views/NotFound.vue");
import i18n from "@/i18n";
Vue.use(VueRouter);
const routes = [
{
path: "/",
redirect: `/${i18n.locale}/`,
},
// USE CODE BELOW FOR DYNAMIC ROUTES
{
path: "/:lang/",
component: {
render(c) {
return c("router-view");
},
},
children: [
{
path: "",
name: "Home",
component: {
render(c) {
return c(Home);
},
},
},
{
path: "services",
name: "Services",
component: {
render(c) {
return c(Services);
},
},
},
{
path: "404",
name: "NotFound",
component: NotFound,
},
{
path: "*",
redirect: {
name: "NotFound",
},
},
],
},
];
const router = new VueRouter({
mode: "history",
routes,
scrollBehavior(to, from, savedPosition) {
if (to.hash) {
return {
selector: to.hash,
// , offset: { x: 0, y: 10 }
};
}
},
});
export default router;
To Reproduce Steps to reproduce the behavior:
- create vue app
- install vue-i18n for localization
- create routes for the localization
- add vue-cli-plugin-prerender-spa
- build the app
- check dist folder
Expected behavior index.html should be in the dist folder after the app is built
Screenshots
/dist/
Additional context Package version: 1.1.6 Vue version: 2.6.12 Vue CLI version: 4.5.4
edit: previous image was captured during an overwrite of the dist directory
I have the same problem in vue3 :
path: "/:lang", component: { render(c) { return c("router-view"); }, },
with warnings :