vuecli3.0 htmlWebpackPlugin 报 ReferenceError: BASE_URL is not defined 错误

<head>   

<link rel="icon" href="<%= BASE_URL %>favicon.ico"> // 这里BASE_URL报错

</head>

-------------------------------------------------

vue.config.js

config.plugins.push(
      new HtmlWebpackPlugin({
        template: ‘./public/index.html‘,
        inject: true,
        hash: new Date().getTime(),
        url: BASE_URL,  //需要这里传参
        minify: {
          removeComments: true,
          collapseWhitespace: true,
          removeAttributeQuotes: true
        },
        chunksSortMode: ‘manual‘
      })
    )
 
--------------------------------

<head>   

<link rel="icon" href="<%= htmlWebpackPlugin.options.url %>favicon.ico"> //改成这种就ok了

</head>

文章来自:https://www.cnblogs.com/ctb-web/p/11944467.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3