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>

posted @ 2019-11-27 18:21  陈健儿  阅读(3578)  评论(1编辑  收藏  举报