After updating vue-cli 5, the problem that assets under the public path will be reported in Less is solved

Original link: https://www.wikimoe.com/?post=278

donate.png

The root cause is that the css-loader used by the new vue-cli will treat “/a.png” as “require(‘/a.png’)” by default.

At this point, you need to configure vue.config.js, add the following content

 css: {  
   
    loaderOptions: {  
   
      css: {  
   
        url: {  
   
          filter: url => url[0] !== '/'  
   
        }  
   
      }  
   
    }  
   
  }

Reference link: https://github.com/vuejs/vue-cli/issues/7032

This article is transferred from: https://www.wikimoe.com/?post=278
This site is only for collection, and the copyright belongs to the original author.