Skip to content

Commit bff613e

Browse files
author
Eugene Matvejev
authored
Merge pull request #3 from learn-symfony/master
sync with master
2 parents 2cafd93 + 3d440d4 commit bff613e

File tree

9 files changed

+170
-2373
lines changed

9 files changed

+170
-2373
lines changed

README.md

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,70 @@
1-
# css-compiler
2-
compiles SASS/LESS and Compass, available though Composer
1+
[![Latest Stable Version](https://poser.pugx.org/eugene-matvejev/css-compiler/version)](https://packagist.org/packages/eugene-matvejev/css-compiler)
2+
[![Total Downloads](https://poser.pugx.org/eugene-matvejev/css-compiler/downloads)](https://packagist.org/packages/eugene-matvejev/css-compiler)
3+
[![License](https://poser.pugx.org/eugene-matvejev/css-compiler/license)](https://packagist.org/packages/eugene-matvejev/css-compiler)
4+
[![composer.lock](https://poser.pugx.org/eugene-matvejev/css-compiler/composerlock)](https://packagist.org/packages/eugene-matvejev/css-compiler)
5+
6+
7+
# PHP CSS Compiler
8+
_can be triggered from composer's script's section: compiles LESS|SASS|Compass_
9+
10+
# How to use:
11+
```
12+
composer require "eugene-matvejev/css-compiler"
13+
```
14+
if you have problem with min-stability you can use this solution in '_require(-dev)_':
15+
_example_:
16+
```
17+
"require": {
18+
"eugene-matvejev/css-compiler": "^0.1",
19+
"leafo/scssphp-compass": "@dev",
20+
"leafo/scssphp": "@dev"
21+
}
22+
```
23+
24+
### add callback into into composer's __scripts__:
25+
```
26+
"EM\\CssCompiler\\Handler\\ScriptHandler::compileCSS"
27+
```
28+
_example_:
29+
```
30+
"scripts": {
31+
"post-update-cmd": "@custom-events",
32+
"post-install-cmd": "@custom-events",
33+
"custom-events": [
34+
"EM\\CssCompiler\\Handler\\ScriptHandler::compileCSS"
35+
]
36+
}
37+
```
38+
### add _css-compiler_ information inside of the _extra_ composer configuration
39+
* _format_: compression format
40+
* _input_: array of relative paths to the composer.json, all files will be picked up recursivly inside of the directory
41+
* _output_: relative file path to the composer.json, where to save output (hard-copy)
42+
43+
_example_:
44+
```
45+
"extra": {
46+
"css-compiler": [
47+
{
48+
"format": "compact",
49+
"input": [
50+
"tests/shared-fixtures/scss"
51+
],
52+
"output": "var/cache/assets/scss.css"
53+
},
54+
{
55+
"format": "compact",
56+
"input": [
57+
"tests/shared-fixtures/sass"
58+
],
59+
"output": "var/cache/assets/sass.css"
60+
},
61+
{
62+
"format": "compact",
63+
"input": [
64+
"tests/shared-fixtures/compass/app.scss"
65+
],
66+
"output": "var/cache/assets/compass.css"
67+
}
68+
]
69+
}
70+
```

ScriptHandler.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,17 @@ public static function compileCSS(Event $event)
2626
}
2727

2828
$processor = new Processor($event->getIO());
29-
30-
exec('rm -rf ' . __DIR__ . '/var/*');
31-
29+
$prefix = getcwd();
3230
foreach ($configs as $config) {
3331
if (!is_array($config)) {
3432
throw new \InvalidArgumentException('The extra.css-compiler should contain only configuration objects.');
3533
}
3634

3735
foreach ($config['input'] as $item => $value) {
38-
$processor->attachFiles(__DIR__ . "/{$value}", __DIR__ . "/{$config['output']}");
36+
$processor->attachFiles("{$prefix}/{$value}", "{$prefix}/{$config['output']}");
3937
}
4038

41-
$processor->processFiles($config['format'] ?? 'compact');
39+
$processor->processFiles(isset($config['format']) ? $config['format'] : 'compact');
4240
}
4341

4442
$processor->saveOutput();

composer.json

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "eugenematvejev/css_compiler",
3-
"description": "compiles css assets from sass or less on composer events",
2+
"name": "eugene-matvejev/css-compiler",
3+
"description": "compiles SASS and LESS assets on composer's callback",
44
"type": "lib",
55
"license": "MIT",
66
"authors": [
@@ -21,51 +21,12 @@
2121
}
2222
},
2323
"require": {
24-
"php": ">= 7.0.4",
24+
"php": ">= 5.5.9",
2525
"leafo/lessphp": "^0.5",
26-
"leafo/scssphp": "0.6.3 as dev-master",
2726
"leafo/scssphp-compass": "dev-master"
2827
},
2928
"require-dev": {
3029
"composer/composer": "^1.1",
31-
"phpunit/phpunit": "^5.4"
32-
},
33-
"minimum-stability": "dev",
34-
"scripts": {
35-
"post-update-cmd": "@custom-events",
36-
"post-install-cmd": "@custom-events",
37-
"custom-events": [
38-
"EM\\CssCompiler\\Handler\\ScriptHandler::compileCSS"
39-
]
40-
},
41-
"config": {
42-
"bin-dir": "bin/"
43-
},
44-
"extra": {
45-
"css-compiler": [
46-
{
47-
"format": "compact",
48-
"force": true,
49-
"input": [
50-
"tests/shared-fixtures/scss"
51-
],
52-
"output": "var/cache/assets/scss.css"
53-
},
54-
{
55-
"format": "compact",
56-
"force": true,
57-
"input": [
58-
"tests/shared-fixtures/sass"
59-
],
60-
"output": "var/cache/assets/sass.css"
61-
},
62-
{
63-
"format": "compact",
64-
"input": [
65-
"tests/shared-fixtures/compass/app.scss"
66-
],
67-
"output": "var/cache/assets/compass.css"
68-
}
69-
]
30+
"phpunit/phpunit": "^4.8"
7031
}
7132
}

0 commit comments

Comments
 (0)