Skip to content

Commit 7c08cdb

Browse files
Updates readme with version 4.1 changes.
1 parent 5b046b4 commit 7c08cdb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Previously a part of clean-css it's a separate package since clean-css 4.0.
2121
- [Install](#install)
2222
- [Use](#use)
2323
* [Important: 4.0 breaking changes](#important-40-breaking-changes)
24+
* [What's new in version 4.1](#whats-new-in-version-41)
2425
* [CLI options](#cli-options)
2526
* [Compatibility modes](#compatibility-modes)
2627
* [Formatting options](#formatting-options)
@@ -29,6 +30,7 @@ Previously a part of clean-css it's a separate package since clean-css 4.0.
2930
+ [Level 0 optimizations](#level-0-optimizations)
3031
+ [Level 1 optimizations](#level-1-optimizations)
3132
+ [Level 2 optimizations](#level-2-optimizations)
33+
* [As a module](#as-a-module)
3234
- [FAQ](#faq)
3335
* [How to optimize multiple files?](#how-to-optimize-multiple-files)
3436
* [How to specify a custom rounding precision?](#how-to-specify-a-custom-rounding-precision)
@@ -72,6 +74,16 @@ clean-css-cli 4.0 introduces some breaking changes:
7274
* `--keep-breaks` option is replaced with `--format keep-breaks` to ease transition;
7375
* `--skip-aggressive-merging` option is removed as aggressive merging is replaced by smarter override merging.
7476

77+
## What's new in version 4.1
78+
79+
clean-css-cli 4.1 introduces the following changes / features:
80+
81+
* `--remove-inlined-files` option for removing files inlined in <source-file ...> or via `@import` statements;
82+
* adds glob pattern matching to source paths, see [example](#how-to-optimize-multiple-files);
83+
* allows non-boolean compatibility options, e.g. `--compatibility selectors.mergeLimit=512`;
84+
* extracts CLI into an importable module, so it can be reused and enhanced if needed;
85+
* adds `beforeMinify` callback as a second argument to CLI module, see [example use case](#as-a-module).
86+
7587
## CLI options
7688

7789
```shell
@@ -275,6 +287,24 @@ There is an `all` shortcut for toggling all options at the same time, e.g.
275287
cleancss -O2 all:off;removeDuplicateRules:on one.css
276288
```
277289
290+
# As a module
291+
292+
clean-css-cli can also be used as a module in a way of enhancing its functionality in a programmatic way, e.g.
293+
294+
```js
295+
#!/usr/bin/env node
296+
297+
var cleanCssCli = require('clean-css-cli');
298+
299+
return cleanCssCli(process, function beforeMinify(cleanCss) {
300+
cleanCss.options.level['1'].transform = function (propertyName, propertyValue) {
301+
if (propertyName == 'background-image' && propertyValue.indexOf('../valid/path/to') == -1) {
302+
return propertyValue.replace('url(', 'url(../valid/path/to/');
303+
}
304+
}
305+
});
306+
```
307+
278308
# FAQ
279309
280310
More answers can be found in [clean-css FAQ section](https://github.com/jakubpawlowicz/clean-css#faq).
@@ -287,6 +317,12 @@ It can be done by passing in paths to multiple files, e.g.
287317
cleancss -o merged.min.css one.css two.css three.css
288318
```
289319
320+
Since version 4.1.0 it can also be done using glob pattern matching, e.g.
321+
322+
```shell
323+
cleancss -o merged.min.css *.css
324+
```
325+
290326
## How to specify a custom rounding precision?
291327
292328
The level 1 `roundingPrecision` optimization option accept a string with per-unit rounding precision settings, e.g.

0 commit comments

Comments
 (0)