Css-loader: Not able to load image url from css file + webpack 4

Created on 25 May 2018  路  2Comments  路  Source: webpack-contrib/css-loader

Hello,
I tried to render image in scss file but cannot. Using require() in js is ok. But cannot load image url in css file

Here is my config
{
// Preprocess our own .scss files
test: /.scss$/,
exclude: /node_modules/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
my sccs script:

background: url("images/header/book.png") no-repeat;

Most helpful comment

I struggled with this for some time with my upgrade to webpack v4. Until I finally found the newer webpack-image-loader so I wrote up a quick post here with a code example:
https://medium.com/@albertomadueno/webpack-v4-config-d6cee480a071
also README here: https://github.com/tcoopman/image-webpack-loader

All 2 comments

Please use issue template, also you need url-loader or file-loader for assets.

I struggled with this for some time with my upgrade to webpack v4. Until I finally found the newer webpack-image-loader so I wrote up a quick post here with a code example:
https://medium.com/@albertomadueno/webpack-v4-config-d6cee480a071
also README here: https://github.com/tcoopman/image-webpack-loader

Was this page helpful?
0 / 5 - 0 ratings