提问者:小点点

Vue CLI 3预渲染spa插件


索引中的输出。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运行构建”时,它会不断返回“构建用于生产......”没有任何事情发生。有人知道这个问题吗?


共1个答案

匿名用户

好吧,我发现了问题。在索引中。html我有一句话:

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