chrisvfritz / prerender-spa-plugin

Prerenders static HTML in a single-page application.
MIT License
7.31k stars 633 forks source link

I have a Vue multi-page app, after prerender, all html files look the same. #460

Open huanhunx opened 3 years ago

huanhunx commented 3 years ago

First of all, is this plugin support multi-page app?

My project is some subpages of our main website. so this project has no index route. But the plugin runs error with notice: can not find /path/to/project/index.html. So i add an empty entry for index route (every page's entry file provide a variable for this pages content). Entries looks like this: (in index page, the value of content and title variable is empty string)

import { config, startApp } from "../main";

// different pages import their own file
const {
  content,
  title,
} = require("@/assets/articles/copyright-dispute-policy");
startApp({
  ...config,
  provide: {
    content,
    title,
  },
});

After compile without prerender-spa-plugin, the output file runs good. Every pages import their own script, like this: image

But if I import this plugin, the output files goes wrong, all html files look the same, they import the same script as index route, like this: image

So the pages title and content is empty string.

this is what my vue.config.js file looks like. Pages config: image

Plugin config: image

I don't know if my codes wrong or plugin don't support multi-page app. Please help me, thanks a lot.

huanhunx commented 3 years ago

I have solved it. I have to push multi PrerenderSPAPlugins to plugin property. Example vue.config.js: image image