简体   繁体   中英

Compile many SCSS files in one CSS file in PHP

I try to compile my SCSS files with the following script:

use Leafo\ScssPhp\Compiler;
...
$scss = new Compiler();
$scss->addImportPath('/home/vagrant/Code/myapp/storage/app/scss/');
$cssContent = $scss->compile('@import "style.scss";');

The file style.scss has the following content:

////
/// 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/**/*";

The compiled css looks like:

@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/**/*";

So, the compiler compiled only the file style.scss, but did not import any of the files, which should be imported.

I tried to add all the imports manually, like:

$cssContent .= $scss->compile('@import "bourbon/app/assets/stylesheets/bourbon";');
$cssContent .= $scss->compile('@import "generic/variables/*";');

But it adds just the following two lines to the CSS code:

@import "bourbon/app/assets/stylesheets/bourbon";
@import "generic/variables/*";

use sccs.inc.php

for More details Visit http://leafo.net/scssphp/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM