Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCSSPHP not finding imports #2

Open
iamdriz opened this issue Dec 3, 2013 · 5 comments
Open

SCSSPHP not finding imports #2

iamdriz opened this issue Dec 3, 2013 · 5 comments

Comments

@iamdriz
Copy link

iamdriz commented Dec 3, 2013

Hi me again :)

I've download the latest version of shrink to test the inclusion of Scssphp to do the compiling of Sass files via PHP instead of Ruby.

It works fine for single files but not for imports.

e.g.

If I pass it a file with JUST the following inside:

@import "compass/utilities";
@import "compass/typography";
@import "compass/css3";

The returned code will be empty.

To test this further I amended the code like so:

$code = $scss->compile(file_get_contents($file->read()));

echo $code; exit;

and I get the following errors:

Warning (2): file_get_contents(@import "compass/utilities";
@import "compass/typography";
@import "compass/css3";
) [function.file-get-contents]: failed to open stream: No such file or directory [APP/Plugin/Shrink/Lib/ShrinkType/ShrinkCompiler/ShrinkCompilerScss.php, line 36]

So I'm wondering is the plugin struggling to find the files? Or this error just because of my test? Either way the imports are not working :) Any ideas?

Thanks once again.

@trentrichardson
Copy link
Owner

Your change with the file_get_contents() won't work. $file is a CakePHP File object where ->read() is the contents of the file, so that part should be working fine (it was for me). One of my tests were including files earlier and it worked fine, however they were in the same directory. It looks like your import files are in the "compass" directory. Try going back to my commit earlier (where I added scssphp support) and add in another import path:

http://leafo.net/scssphp/docs/#import_paths

So you should have something like:

$scss = new scssc();
$scss->setImportPaths(array($file->Folder->path, 'path/to/directory/compass'));
$code = $scss->compile($file->read());

I think thats all the issue is. Just try playing with that path to the compass directory. If that works perhaps I should add a shrink option to pass in an array of import paths to append.

@trentrichardson
Copy link
Owner

Also be sure you have debug in core.php at 1 or higher to watch for any errors.

@iamdriz
Copy link
Author

iamdriz commented Dec 3, 2013

Still can't get it to work using:

$scss->setImportPaths(array($file->Folder->path, APP . WEBROOT_DIR . '/sass/compass'));

and dumping that out gives: /nfs/c03/h02/mnt/52704/domains/dev.driz.co.uk/html/2013/app/webroot/sass/compass which is the correct path to where the compass files live.

But that been said, should you need to do all that? When I tried this with the Less version it imported all the files automatically fine without any extra manual work :)

Thanks.

@trentrichardson
Copy link
Owner

What happens if you do:

debug($file->read());

Since scssphp wants only the contents of the file and not the file path you will likely have to set at least one import path (the location of the file).

What you might could do to possibly avoid setting the import stuff is to change the compile() to somethink like:

$code = $scss->compile('@import "'. $file->path .'"');

Then maybe it can see the full path to the file and not need to set extra imports.

@iamdriz
Copy link
Author

iamdriz commented Dec 3, 2013

The debug gives me:

 /app/Plugin/Shrink/Lib/ShrinkType/ShrinkCompiler/ShrinkCompilerScss.php (line 31)

'@import "compass/utilities";
@import "compass/typography";
@import "compass/css3";
'

and trying that second line you posted doesn't make the import work either :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants