我在尝试构建时遇到以下错误:
Building for production...Error: ENOENT: no such file or directory, stat '/Users/me/Code/project/index.html'
包:"prerender-spa-plugin": "^3.1.0"
文件:vue.config.js
const PrerenderSPAPlugin = require('prerender-spa-plugin');
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer;
const path = require('path');
module.exports = {
configureWebpack: config => {
if (process.env.NODE_ENV !== 'production') return;
return {
plugins: [
new PrerenderSPAPlugin({
staticDir: path.join(__dirname),
routes: ['/'],
minify: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
decodeEntities: true,
keepClosingSlash: true,
sortAttributes: true,
},
renderer: new Renderer({
renderAfterDocumentEvent: 'render-event',
}),
}),
],
};
},
};
我没有任何路由,只有一个index.html页面。
此外,当我运行yarn build
并得到这个错误时,我试图终止终端中的进程,但它一直返回Building for production...
而没有发生任何事情,我必须退出终端才能停止它。
编辑:我也尝试过添加staticDir: path.join(__dirname, './public')
,但是构建挂起了,没有任何错误。
https://stackoverflow.com/questions/50123821
复制相似问题