postcss / postcss-url

PostCSS plugin to rebase url(), inline or copy asset.
MIT License
377 stars 59 forks source link

asset paths wont work in @import files #120

Closed digitalkaoz closed 6 years ago

digitalkaoz commented 6 years ago

hey,

here a tiny setup:

//main.scss

@import "deps/foo"

#bar {
  background: url(./img/bar.jpg)
}
//deps/foo.scss
#foo {
  background: url(../img/foo.jpg)
}

if i use this config:

{
            url: "inline",
            maxSize: 10,
            optimizeSvgEncode: true,
            fallback: "copy",
            assetsPath: "./dist_img",
            shrink: 8,
            useHash: true,
            hashOptions: {
                append: true
            }
        }

#bar works fine, the image is copied #foo does not because the import is somehow resolved to main.scss and the defined path ../img/foo.jpg doesnt match anymore...

anyone has an idea?

digitalkaoz commented 6 years ago

comes out, its a sass problem which doesnt resolve the paths and generating a css with wrong paths

duannx commented 8 months ago

Hi @digitalkaoz, I understand that the problem comes from Sass. But what is the common way to deal with it? I am surprised that Sass still has this problem and I can not find a solution elsewhere on the internet