我尝试使用以下脚本编译我的SCSS文件:
use Leafo\ScssPhp\Compiler;
...
$scss = new Compiler();
$scss->addImportPath('/home/vagrant/Code/myapp/storage/app/scss/');
$cssContent = $scss->compile('@import "style.scss";');
文件style.scss具有以下内容:
////
/// Main Stylesheet
/// this file holds includes all files for the stylesheet
////
// a cleaner way to to breakpoints/media queries
// @source
// http://breakpoint-sass.com/
@import "breakpoint-sass/stylesheets/breakpoint";
// Helpful mixins
// @source
// http://bourbon.io/docs/
@import "bourbon/app/assets/stylesheets/bourbon";
// set default variables
@import "generic/variables/*";
// override default variables and set custom variables
@import "custom/generic/variables/*";
// generic - do not customize this files!
// files are generic and can be updated from base theme
@import "generic/*";
@import "vendor/**/*";
@import "objects/**/*";
// run through stuff in source folders, just patternlab stuff
@import "../source/**/*.scss";
// custom modifications
@import "custom/**/*";
编译的css看起来像:
@import "breakpoint-sass/stylesheets/breakpoint";
@import "bourbon/app/assets/stylesheets/bourbon";
@import "generic/variables/*";
@import "custom/generic/variables/*";
@import "generic/*";
@import "vendor/**/*";
@import "objects/**/*";
@import "../source/**/*.scss";
@import "custom/**/*";
因此,编译器只编译了文件style.scss,但没有导入任何应该导入的文件。
我尝试手动添加所有导入,例如:
$cssContent .= $scss->compile('@import "bourbon/app/assets/stylesheets/bourbon";');
$cssContent .= $scss->compile('@import "generic/variables/*";');
但它只在CSS代码中添加以下两行:
@import "bourbon/app/assets/stylesheets/bourbon";
@import "generic/variables/*";