Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

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

Open
huanhunx opened this issue Jun 25, 2021 · 1 comment

Comments

@huanhunx
Copy link

huanhunx commented Jun 25, 2021

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

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

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

No branches or pull requests

1 participant