The problem of the invalidation of the background map path after the packaging of vue-cli 3.x version

after the vue-cli 3 is packaged, the path of the background image is still invalid and my heart is tired. Do you want to roll back to vue-cli 2

?

how to solve it?


you can upload the background image to the server first, and then use the absolute address in vue, that is, the URL of the image resource, so that it will not be invalidated.


small images are considered to be directly transferred to base64 to be packaged into the code. If you have a big picture, take a look at the configuration.

clipboard.png
add.


I don't know if the landlord has solved it.

look at the official documentation, it seems that you want to overwrite (uncertain) in vue.config.js

I used a silly method to copy the img folder directly into css


  chainWebpack: config => {
    config.resolve.alias
      .set('assets', resolve('src/assets'))
      .set('@', resolve('src'))
    config.output.filename('[name].js?[hash]').end()
  }
// .vue
background: url('~assets/images/right-glay.png')

~ will parse assets as a module, and the path will not be wrong after packaging

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37f0c-2c0ee.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37f0c-2c0ee.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?