Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing index.html when redirecting routes with vi18n #140

Open
carljustineoyales opened this issue Sep 13, 2020 · 2 comments
Open

Missing index.html when redirecting routes with vi18n #140

carljustineoyales opened this issue Sep 13, 2020 · 2 comments

Comments

@carljustineoyales
Copy link

carljustineoyales commented Sep 13, 2020

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
Copy link
Author

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

@bouachalazhar
Copy link

I have the same problem in vue3 :

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

with warnings :
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants