Skip to content

Missing index.html when redirecting routes with vi18n #140

@carljustineoyales

Description

@carljustineoyales

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions