grunt-inline icon indicating copy to clipboard operation
grunt-inline copied to clipboard

CSS background-image path gets messed up

Open curtisblackwell opened this issue 11 years ago • 6 comments

When grunt-inline inlines my css, it messes up the path to my background images.

background: #463862 url(/assets/img/mountain.jpg) no-repeat center top fixed;

becomes

background: #463862 url(../../../../../assets/img/mountain.jpg) no-repeat center top fixed;

If I use

background: #463862 url(assets/img/mountain.jpg) no-repeat center top fixed;

I end up with

background: #463862 url(css/assets/img/mountain.jpg) no-repeat center top fixed;

curtisblackwell avatar May 18 '14 02:05 curtisblackwell

@curtisblackwell more information would be better :)

is the project structure like bellow?: /index.html /assets/css/style.css /assets/img/mountain.jpg

and in index.html, there's something like:

<link href="assets/css/style.css" rel="stylesheet" />

chyingp avatar May 18 '14 15:05 chyingp

The structure is as you say, but the href was /assets/css/style.css.

Using assets/css/style.css works, though.

curtisblackwell avatar May 19 '14 00:05 curtisblackwell

@curtisblackwell it seems it's because grunt-inline doesn't support absolute path yet. It will be supported in the near feature, and I will let you know then :)

chyingp avatar May 19 '14 02:05 chyingp

Yep. Thanks!

curtisblackwell avatar May 19 '14 02:05 curtisblackwell

Hi chyingp A similar issue occurs with protocol-relative urls. url('//netdna.bootstrapcdn.com/font-awesome/3.2.0/font/fontawesome-webfont.eot?v=3.2.0') becomes url(../../../../../../netdna.bootstrapcdn.com/font-awesome/3.2.0/font/fontawesome-webfont.eot?v=3.2.0)

In my build, this url survives recess, uncss, and then gets altered by grunt-inline. Thanks for checking it out. Monte

monte-hayward avatar Jun 16 '14 03:06 monte-hayward

@monte-hayward this problem is not the same as the one @curtisblackwell mentioned. I've put your issue in #27 , let's discuss it there. :)

chyingp avatar Jun 16 '14 05:06 chyingp