Answer the question
In order to leave comments, you need to log in
How to setup prerender-spa-plugin + vue?
I am trying to set up the prerender-spa plugin for my application.
Must be configured for multiple pages.
I do as in the documentation (Vue.js 2 Router)
I added the necessary parameters for the filewebpack.prod.config.js
const PrerenderSPAPlugin = require('prerender-spa-plugin')
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer
const webpackConfig = merge(baseWebpackConfig, {
...
plugins: [
// == PRERENDER SPA PLUGIN == //
new PrerenderSPAPlugin({
staticDir: path.join(__dirname, '../dist'),
routes: ['/', '/test'],
renderer: new Renderer({
inject: {
foo: 'bar'
},
headless: false,
renderAfterDocumentEvent: 'render-event'
})
}),
...
main.js
new Vue({
el: '#app',
router,
render: h => h(App),
mounted () {
// You'll need this for renderAfterDocumentEvent.
document.dispatchEvent(new Event('render-event'))
}
})
App.vue
<div id="app" data-server-rendered="true">
Answer the question
In order to leave comments, you need to log in
Solved the problem.
Actually there was no problem)
I launched the assembled version with the help serve
Didn't work.
And it worked withhttp-server
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question