Webpack separates and packages the image referenced in css,css separately. How to solve this problem?

now my project is to package css and js separately, and the directory structure after packaging is the same as before.

before packing:

csscssimages../csscss../../

:

webpack.config.js


csscss

csscss

I would like to ask all the great gods, what can be done to solve this problem? Can you package the corresponding pictures into the corresponding folder? I am a webpack rookie, the configuration is a little messy, I hope you will forgive me!

Feb.28,2021

output configuration with a publicPath


path is the output path of all webpack files, and must be an absolute path

:outputjs,url-loaderHtmlWebpackPluginhtml
path

publicPath does not affect the path to the generated file

css

you need to add a publicPath if you want to do so

Menu