繁体   English   中英

Vue CLI 3 prerender-spa-plugin

[英]Vue CLI 3 prerender-spa-plugin

我已经尝试通过Vue CLI 3的npm包prerender-spa-plugin来预渲染SPA的路由,并且在运行“ npm run build”后得到了不错的输出: 在此处输入图片说明

index.html中的输出是错误:

 <html> <head> </head> <body>Html Webpack Plugin: <pre> ReferenceError: BASE_URL is not defined - index.html:96 C:/Users/Fred/v2/public/index.html:96:11 - index.html:99 0971.module.exports C:/Users/Fred/v2/public/index.html:99:3 - index.js:284 Promise.resolve.then [v2]/[html-webpack-plugin]/index.js:284:18 </pre> </body> </html> 

我的vue.config.js是这样的:

 const path = require('path'); const PrerenderSPAPlugin = require('prerender-spa-plugin'); var HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { configureWebpack: { plugins: [ new HtmlWebpackPlugin({ template: './public/index.html', inject: false }), new PrerenderSPAPlugin({ staticDir: path.join(__dirname, './dist'), routes: ['/', '/om-guldbaek', '/om/:id', '/aktiviteter', '/aktivitet/:id', '/foreninger', '/forening/:id', '/begivenheder', '/begivenhed/:id', '/gdpr', '/institutioner', '/institution/:id', '/login', '/nyheder', '/nyhed/:id', '/kontakt', '/registreringer'], }) ], }, }; 

当我在VSCode中运行“ npm run build”时,它始终返回“ Building for production ...”。 有人知道这个问题吗?

好吧,我发现了问题。 在index.html中,我一行:

 <link rel="icon" href="<%= BASE_URL %>favicon.ico"> 

所以现在固定了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM