peteboere / css-crush

CSS preprocessor.
http://the-echoplex.net/csscrush
MIT License
537 stars 51 forks source link

@import with paths outside of working directory #12

Closed lencioni closed 12 years ago

lencioni commented 12 years ago

I have my CSS directory set up at http://mysite.com/css/ and some CSS that is part of a different project located at http://mysite.com/js/project/css/style.css. Using @import with CSS Crush, is there a way to bring that CSS file into the mix? I've tried the following with no luck:

@import "/js/project/css/style.css";
@import "//js/project/css/style.css";
@import "../js/project/css/style.css";
@import "/absolute/file/path/to/js/project/css/style.css";
peteboere commented 12 years ago

The first three paths look ok to me.

In a typical server configuration this should work fine. Are there any Apache rewrite rules or aliases coming into play?

lencioni commented 12 years ago

I don't think so.

I removed the @ from file_get_contents on 61 of Importer.php and I get an error like this:

Warning: file_get_contents(/path/to/webroot/css//js/project/css/style.css) [function.file-get-contents]: failed to open stream: No such file or directory in /path/to/css-crush/CssCrush/lib/Importer.php on line 61

I symlinked the files I needed into that directory as a workaround for now, but it would be nice to have this working.

peteboere commented 12 years ago

From that error message the file is not being found because it doesn't exist at that path.

Does the system path in the error message look right to you? (The document root path might be incorrect)

Are you using the latest version from the master branch (1.3.2)?

lencioni commented 12 years ago

Yes, that is definitely what that error is saying. The document root path looks good up until the /css/ part. It is trying to get the file at /path/to/webroot/css//js/project/css/style.css when it should be trying to get the file at /path/to/webroot/js/project/css/style.css

I have CSS Crush in a directory outside of the web document root, perhaps that is part of the problem? (e.g. /path/to/lib/css-crush/ vs /path/to/www/)

Yes, I am using the latest from the master branch (commit c68012b64f3000cc54467a025901f9e1da7b1ac9).

peteboere commented 12 years ago

Ok, I've found a regression from some recent refactoring. It occurs when using root relative urls.

I've pushed a fix up to the test branch if you want to try it out.

lencioni commented 12 years ago

The test branch seems to work for me. Thanks!

peteboere commented 12 years ago

Now in master branch (tagged v1.3.3)