The background image path does not work in the css file using gulp js


I am working on a project where I am concatenating all files, minifying and renaming by gulp.

When I write an image path as a background image in my main css file it is not working in the minified file. Actually I am unable to set the image path as it is getting compiled in my minified file which is in another directory.

My File route flow

    assets -->

    dist -->


I have put an image file inside the assets/img folder and am calling that file inside my main.css

My gulp.js

return gulp.src([
        .pipe(cleanCSS({compatibility: 'ie8'}))
         browsers: ['last 2 versions'],
         cascade: false

and in my main.css

    background:url('../img/black-multiply-bg.png') 0 0 repeat;

I am seeing this console error for image file not found

http://localhost/projects/P-09-sakha/html/dist/css/assets/img/black-multiply-bg.png 404 (Not Found)

The source is showing the dist folder. I have also checked with gulp-css-url-adjuster but still am unable to make it work.

I only got some experience with Grunt, not Gulp unfortunately. But since I did run into something similar in the past, I'll tell you what I did.

I used the replace functionality to apply a regex replacing the "wrong" urls for the right ones.

In my case: replace: [{files: 'index.html', regex: /\.\.\/dist\/css/g, replacement: 'css'}], replacing all ../dist/css for css in the index.html file. For example, <link href="../dist/css/style.css" /> will become <link href="css/style.css" />.

I'm sure Gulp has something similar.