chrisvfritz / prerender-spa-plugin

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

[prerender-spa-plugin] Unable to prerender all routes! #366

Open hyteraesa opened 4 years ago

hyteraesa commented 4 years ago

I think prerender-spa-plugin is very good I tried to use it on my website, but the local build succeeded, but the build on jenkins failed

  • Building for buildUat... Browserslist: caniuse-lite is outdated. Please run next command npm update [prerender-spa-plugin] Unable to prerender all routes! ERROR Failed to compile with 1 errors12:29:37 AM

error

[prerender-spa-plugin] Unable to prerender all routes!

ERROR Build failed with errors. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! proj-hyt-web@0.1.0 build:uat: vue-cli-service build --mode buildUat npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the proj-hyt-web@0.1.0 build:uat script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2020-02-18T00_29_37_088Z-debug.log Build step 'Execute shell' marked build as failure Finished: FAILURE

My configuration information:

` vue.config.js--> const path = require('path') const PrerenderSPAPlugin = require('prerender-spa-plugin'); const Renderer = PrerenderSPAPlugin.PuppeteerRenderer

module.exports = { publicPath: '/', // assetsDir: './cn', configureWebpack: { resolve: { symlinks: false, alias: { // Make sure our version of ag-grid & vue is always loaded. // This is needed for yarn link / npm link to work and prevent duplicate versions of these libs // being loaded 'ag-grid-community/main': path.resolve(dirname, 'node_modules/ag-grid-community/main.js'), 'ag-grid-community$': path.resolve(__dirname, 'node_modules/ag-grid-community/main.js'), vue$: path.resolve(dirname, 'node_modules/vue/dist/vue.common.js'), assets: path.resolve(dirname, 'src/assets/'), components: path.resolve(dirname, 'src/components/'), utils: path.resolve(dirname, 'src/utils/'), jquery: path.resolve(dirname, 'node_modules/jquery/dist/jquery.min.js'), } }, performance: { hints: false }, plugins: [ new PrerenderSPAPlugin({ staticDir: path.join(__dirname, 'dist'), routes: ['/index/home'], postProcess(renderedRoute) { renderedRoute.html = renderedRoute.html .replace(/<script (.*?)>/g, <script $1 defer>) .replace(id="app", id="app" data-server-rendered="true")

                return renderedRoute
              },
            renderer: new Renderer({
                inject: {},
                headless: true,
                renderAfterElementExists: `[data-view]`
            })
        })
    ]
}

}

router.js ---> import Vue from 'vue' import Router from 'vue-router' import Index from './views/index/index.vue' import Home from './views/index/home.vue'

Vue.use(Router)

export default new Router({ mode: 'history', routes: [ { path: '/', redirect: '/index/home' }, { path: '/index', component: Index, children: [ { path: 'home', component: Home, }... `

torresyb commented 4 years ago

me too

chenxingshuang commented 4 years ago

I encounter the same problem. Do you solve it?

kubajmarek commented 4 years ago

Try changing PuppeteerRenderer maxConcurrentRoutes settings, check readme for example.

WormGirl commented 4 years ago

Try changing PuppeteerRenderer maxConcurrentRoutes settings, check readme for example.

This not work for me

igitcloud commented 4 years ago

Try changing PuppeteerRenderer maxConcurrentRoutes settings, check readme for example.

That's solved my problem!

WormGirl commented 4 years ago

Try changing PuppeteerRenderer maxConcurrentRoutes settings, check readme for example.

This not work for me I am because of the chinese wall, I use facebook login api,the js lib can not be access. It works fine when remove the lib.