From 763eec6c50d056fa7468daea038f06c693e1b1ec Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 14 Sep 2020 00:17:55 -0700 Subject: [PATCH] greenwich - Define compilation task --- .gitignore | 1 + Civi/Compile/Scss.php | 49 ++++++++++++++++++++++++++++++++++++ composer.json | 11 +++++++- ext/greenwich/scss/main.scss | 3 +++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 Civi/Compile/Scss.php create mode 100644 ext/greenwich/scss/main.scss diff --git a/.gitignore b/.gitignore index 09471dd838..4e19702890 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ !/ext/eventcart !/ext/ewaysingle !/ext/greenwich +/ext/greenwich/dist /ext/greenwich/extern !/ext/search !/ext/financialacls diff --git a/Civi/Compile/Scss.php b/Civi/Compile/Scss.php new file mode 100644 index 0000000000..b695a89ce2 --- /dev/null +++ b/Civi/Compile/Scss.php @@ -0,0 +1,49 @@ +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"); + } + } + } + +} diff --git a/composer.json b/composer.json index 39299630d4..a8b3d45c11 100644 --- a/composer.json +++ b/composer.json @@ -282,6 +282,15 @@ "zetacomponents/mail": { "CiviCRM Custom Patches for ZetaCompoents mail": "https://raw.githubusercontent.com/civicrm/civicrm-core/9d93748a36c7c5d44422911db1c98fb2f7067b34/tools/scripts/composer/patches/civicrm-custom-patches-zetacompoents-mail.patch" } - } + }, + "compile": [ + { + "title": "Greenwich SCSS (ext/greenwich/dist/bootstrap3.css)", + "php-method": "\\Civi\\Compile\\Scss::build", + "watch-files": ["ext/greenwich/scss"], + "scss-files": {"ext/greenwich/scss/main.scss": "ext/greenwich/dist/bootstrap3.css"}, + "scss-includes": ["ext/greenwich/scss", "ext/greenwich/extern/bootstrap3/assets/stylesheets"] + } + ] } } diff --git a/ext/greenwich/scss/main.scss b/ext/greenwich/scss/main.scss new file mode 100644 index 0000000000..6ce355c0fe --- /dev/null +++ b/ext/greenwich/scss/main.scss @@ -0,0 +1,3 @@ +#bootstrap-theme { + @import "bootstrap"; +} \ No newline at end of file -- 2.25.1