-
-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18465 from totten/master-greenwich-ext
Greenwich: Add BootstrapCSS support via core extension
- Loading branch information
Showing
16 changed files
with
2,499 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
namespace Civi\Compile; | ||
|
||
class Scss { | ||
|
||
/** | ||
* Compile some SCSS file(s). | ||
* | ||
* NOTE: This function runs during 'composer install', which is a pre-boot | ||
* environment. The composer autoloader has been configured, but no other | ||
* Civi services are online. | ||
* | ||
* @param array $task | ||
* With keys: | ||
* - scss-includes: string[], list of paths with SCSS helper files | ||
* - scss-files: array, key-value mapping with input-files and output-files | ||
* | ||
* @see composer.json | ||
* @link https://github.com/civicrm/composer-compile-plugin/blob/master/doc/tasks.md | ||
*/ | ||
public static function build(array $task) { | ||
$scssCompiler = new \ScssPhp\ScssPhp\Compiler(); | ||
$includes = $task['scss-includes'] ?? []; | ||
foreach ($includes as $include) { | ||
$scssCompiler->addImportPath($include); | ||
} | ||
|
||
if (empty($task['scss-files'])) { | ||
throw new \InvalidArgumentException("Invalid task: required argument 'scss-files' is missing"); | ||
} | ||
foreach ($task['scss-files'] as $inputFile => $outputFile) { | ||
if (!file_exists($inputFile)) { | ||
throw new \InvalidArgumentException("File does not exist: " . $inputFile); | ||
} | ||
$inputScss = file_get_contents($inputFile); | ||
$css = $scssCompiler->compile($inputScss); | ||
$autoprefixer = new \Padaliyajay\PHPAutoprefixer\Autoprefixer($css); | ||
|
||
if (!file_exists(dirname($outputFile))) { | ||
mkdir(dirname($outputFile), 0777, TRUE); | ||
} | ||
$outputCss = $autoprefixer->compile(); | ||
if (!file_put_contents($outputFile, $outputCss)) { | ||
throw new \RuntimeException("Failed to write file: $outputFile"); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.