Webpack - sass loader cannot find images

我的梦境 提交于 2019-11-29 05:32:53

As far as I can see you are actually using the css loader ( "style", "css", "sass", "resolve-url" ) (the "css" part is the "css-loader")

In your sass file(s) you should link to the images using a relative path from the sass file you are editing.

styles
 - somefile.scss
 - another.scss
images
 - someImage.jpg

in somefile.scss, you should link to your image like this:

background-image: url("../images/someImage.jpg);

Do note, that if you want webpack to move those images to your distribution folder (if you are using a system like this) that you will need something like file-loader to copy those files over.

You can use ignore-loader if your images are already in the place where you need them. file-loader will copy the files to your output folder.

To solve this problem I've uploaded this webpack extremly basic configuration to start my projects, I hope it can help everyone who had this problem. Suggestions are all welcome of course.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!