【问题标题】:Vue CLI 3 prerender-spa-pluginVue CLI 3 预渲染水疗插件
【发布时间】: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


    【解决方案1】:

    好的,我找到了问题。在 index.html 我有一行:

    &lt;link rel="icon" href="&lt;%= BASE_URL %&gt;favicon.ico"&gt;

    现在解决了

    【讨论】:

      猜你喜欢
      • 2022-10-06
      • 2017-12-13
      • 2018-08-04
      • 2022-01-18
      • 2021-02-03
      • 2020-02-08
      • 2018-12-13
      • 2019-07-02
      • 2019-03-18
      相关资源
      最近更新 更多