当前位置:首页 > Web开发 > 正文

vuecli3.0 htmlWebpackPlugin 报 ReferenceError: BASE

2024-03-31 Web开发

<head>   

<link 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 href="<%= htmlWebpackPlugin.options.url %>favicon.ico"> //改成这种就ok了

</head>

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

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/42544.html