【发布时间】:2019-06-12 11:53:02
【问题描述】:
我尝试使用带有 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...”,而没有任何事情发生。有人知道这个问题吗?
【问题讨论】:
标签: javascript vue.js single-page-application prerender