The problem of loading image resources in webpack4.0 html and css

when packaging files with webpack, it is found that the application path is always misaligned, and the reference to img in html and css always goes wrong.
this is the entire file directory structure
clipboard.png

html
clipboard.png

css

clipboard.png

webpack.config.js

clipboard.png

clipboard.png

The path to the img file in

html is correct. But the path of css becomes img, in the css directory

Mar.29,2021

upstairs is wrong, you can look here.
here is an example of getting started with webpack4. You can take a look at https://github.com/crlang/eas..


Let's talk about my problem first. Here is my directory structure (the following files / folders named with test are used for this test)

webpack

sass

src/img/test/test.pngdist/img/test/test.png

dist/imgcssdist/css/img

src
publicPath

,publicPathcsspublicPathpublicPathname


dist/imgfileurl


emm,dist/imgQAQfileurlnameQAQ/test.png


namefile'QAQ/',publicPathurl

you can see that this has achieved the desired effect, and the image reference path in the packaged css is fine.
I hope this will provide some help to the landlord. In addition, if there are any mistakes, please point out that, after all, the language of writing something for the first time is a bit confusing (lying down)

.
build==>utils.js:
if (options.extract) {
      return ExtractTextPlugin.extract({
        use: loaders,
        fallback: 'vue-style-loader',
        publicPath:'../../'  //
      })
    } else {
      return ['vue-style-loader'].concat(loaders)
    }
    
 cssjsconfig==>index.js:
build: {
    env: require('./prod.env'),
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',  //'/''./'
    productionSourceMap: false,
    ...
   }
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-1e5ab66-455de.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-1e5ab66-455de.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?