cssgrace icon indicating copy to clipboard operation
cssgrace copied to clipboard

HTTP urls break build

Open jsalonen opened this issue 10 years ago • 11 comments

Use the following test.css to reproduce:

.foo {
  background-image: url("http://www.example.com/image.png");
}

Running results in:

C:\Users\User\Project\node_modules\postcss\lib\lazy-result.js:175
            throw error;
                  ^
Error: ENOENT, no such file or directory 'C:\Users\User\Project\http:\www.example.com\image.png'
    at Error (native)
    at Object.fs.openSync (fs.js:500:18)
    at syncFileToBuffer (C:\Users\User\Project\node_modules\cssgrace\node_modules\image-size\lib\index.js:58:23)
    at module.exports (C:\Users\User\Project\node_modules\cssgrace\node_modules\image-size\lib\index.js:100:18)
    at imageSetMixin (C:\Users\User\Project\node_modules\cssgrace\lib\index.js:423:9)
    at C:\Users\User\Project\node_modules\cssgrace\lib\index.js:477:5
    at C:\Users\User\Project\node_modules\postcss\lib\container.js:119:34
    at C:\Users\User\Project\node_modules\postcss\lib\container.js:104:26
    at Rule.each (C:\Users\User\Project\node_modules\postcss\lib\container.js:91:22)
    at Rule.eachInside (C:\Users\User\Project\node_modules\postcss\lib\container.js:103:21)

Using cssgrace 2.0.2 on Windows 7

jsalonen avatar May 26 '15 09:05 jsalonen

There is no support. Next version fixed.

yisibl avatar May 26 '15 10:05 yisibl

Hi!

Thank you for your quick response.

I don't need cssgrace to resolve background images over HTTP. I just need that the build won't break if I have these urls in my stylesheet.

Looking forward to the next version.

jsalonen avatar May 26 '15 10:05 jsalonen

Hi! How is work on the next version going? I just started a fork to do 2 things:

  1. to split out each rule into its own .js file, instead of keeping them all in one index.js file
  2. to make cssgrace configurable.

I need to disable the image handling in my own project. When I'm done, would you like me to submit a pull request, or are you already working on this?

zenbrent avatar May 28 '15 20:05 zenbrent

I split all the tasks out in my fork at https://github.com/zenbrent/cssgrace

I also made it so it doesn't process images that aren't referenced with image-width or image-height, so if I'm using an image that is served at a different path than it is on my hard drive, there isn't an error. (e.g. I reference url(/images/logo.png), but that's obv. not how it's set up on my computer.) I haven't made it configurable yet, I may do that in the future.

I agree with #10 that some of these features would be best served as a separate project. For my job, I don't want cssgrace to handle my images, but I do want it to make my css work with older browsers! For my personal projects I would love the image handling, but I don't care about very old browsers.

As always, thank you for all your work. This is a very useful and well-done project. :)

zenbrent avatar May 28 '15 23:05 zenbrent

@zenbrent

Thank you for your work!

Yeah, the next version I will "to split out each rule into its own .js file" and add browser config.

Maybe like this:

input:

@browser ie>=8;

.foo {
  display: inline-block;
}

output:

.foo {
  display: inline-block;
}

When you need to be compatible with the old browser, the output of the corresponding syntax sugar.

input:

@browser ie>=6;

.foo {
  display: inline-block;
}

output:

.foo {
  display: inline-block;
  *display: inline;
  *zoom: 1;
}

yisibl avatar May 29 '15 02:05 yisibl

Ok, awesome! Would you like me to submit my changes as a pull request?

zenbrent avatar May 29 '15 18:05 zenbrent

I'm also waiting for this issue's fixed anxiously

miniflycn avatar Jun 04 '15 14:06 miniflycn

@miniflycn I'm sorry, I'll fix it soon.

yisibl avatar Jun 05 '15 02:06 yisibl

@zenbrent No problem! I am looking forward your pull request.

yisibl avatar Jun 05 '15 02:06 yisibl

Hi @yisibl any updates on this?

ghost avatar Oct 01 '15 01:10 ghost

url绝对路径的问题,依旧没有解决啊

mingzepeng avatar Dec 30 '15 03:12 mingzepeng