vue-cli-plugin-prerender-spa icon indicating copy to clipboard operation
vue-cli-plugin-prerender-spa copied to clipboard

Missing index.html when redirecting routes with vi18n

Open carljustineoyales opened this issue 4 years ago • 2 comments

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:

  1. create vue app
  2. install vue-i18n for localization
  3. create routes for the localization
  4. add vue-cli-plugin-prerender-spa
  5. build the app
  6. check dist folder

Expected behavior index.html should be in the dist folder after the app is built

Screenshots /dist/ image

Additional context Package version: 1.1.6 Vue version: 2.6.12 Vue CLI version: 4.5.4

carljustineoyales avatar Sep 13 '20 04:09 carljustineoyales

edit: previous image was captured during an overwrite of the dist directory

carljustineoyales avatar Sep 13 '20 04:09 carljustineoyales

I have the same problem in vue3 :

path: "/:lang", component: { render(c) { return c("router-view"); }, },

with warnings : image

bouachalazhar avatar Sep 21 '22 20:09 bouachalazhar