[prerender-spa-plugin] Unable to prerender all routes! 内网打包报错(Navigation Timeout Exceeded)
[prerender-spa-plugin] Unable to prerender all routes! 内网打包报错
查看错误详情:
\node_modules\prerender-spa-plugin\es6\index.js
在Line 144 添加 console.log('err', err);
即可打印详细错误,如下
\ Building for production...err TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
...
[prerender-spa-plugin] Unable to prerender all routes!
解决:
\node_modules\@prerenderer\renderer-puppeteer\es6\renderer.js
Line 114 由如下代码:
await page.goto(`${baseURL}${route}`, navigationOptions);
改为:
await page.goto(`${baseURL}${route}`, {...navigationOptions, timeout: 0});
build即可通过
如何在项目中配置来修改这个问题:
const PrerenderSPAPlugin = require('prerender-spa-plugin');
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer;
...
new PrerenderSPAPlugin({
staticDir: path.join(__dirname, 'dist'),
routes: [ '/', '/about', '/career', '/careerDetail', '/faq', '/fee', '/feeDetail', '/legal' ],
renderer: new Renderer({
inject: {
foo: 'bar'
},
// renderAfterDocumentEvent: 'render-event',
// renderAfterTime: 5000,
// timeout: 0,
// navigationParams: {
// timeout: 0,
// },
navigationOptions: {
timeout: 0,
},
// maxConcurrentRoutes: 1,
})
}),
...