Skip to content

Commit 3622dcb

Browse files
Bumps clean-css dependency to version 5.0.
1 parent a4f6e10 commit 3622dcb

File tree

7 files changed

+50
-26
lines changed

7 files changed

+50
-26
lines changed

History.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
[5.0.0 / 2021-xx-xx](https://github.com/jakubpawlowicz/clean-css-cli/compare/4.3...HEAD)
2+
==================
3+
4+
* Bumps clean-css dependency to 5.0.
5+
16
[4.3.0 / 2019-04-06](https://github.com/jakubpawlowicz/clean-css-cli/compare/4.2...v4.3.0)
27
==================
38

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Previously a part of clean-css it's a separate package since clean-css 4.0.
2020
- [Node.js version support](#nodejs-version-support)
2121
- [Install](#install)
2222
- [Use](#use)
23+
* [What's new in version 5.0](#whats-new-in-version-50)
2324
* [Important: 4.0 breaking changes](#important-40-breaking-changes)
2425
* [What's new in version 4.1](#whats-new-in-version-41)
2526
* [What's new in version 4.2](#whats-new-in-version-42)
@@ -59,6 +60,14 @@ Note: Global install via -g option is recommended unless you want to execute the
5960
cleancss -o one.min.css one.css
6061
```
6162

63+
## What's new in version 5.0
64+
65+
clean-css-cli 5.0 introduces the following changes / features:
66+
67+
* clean-css 5.0 with loads of bugfixes;
68+
* `--skip-rebase` option has been removed as rebasing URLs is disabled by default now
69+
* `--with-rebase` option is added if you really want URLs rebasing
70+
6271
## Important: 4.0 breaking changes
6372

6473
clean-css-cli 4.0 introduces some breaking changes:
@@ -227,7 +236,7 @@ or a fine-grained configuration given via a string.
227236
228237
Please note that level 1 optimization options are generally safe while level 2 optimizations should be safe for most users.
229238
230-
Important: The `-O` option is using the capital letter O (as in "Oscar"), not the number zero.
239+
Important: The `-O` option is using the capital letter O (as in "Oscar"), not the number zero.
231240
232241
### Level 0 optimizations
233242

index.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function cli(process, beforeMinifyCallback) {
3232
.option('--inline [rules]', 'Enables inlining for listed sources (defaults to `local`)')
3333
.option('--inline-timeout [seconds]', 'Per connection timeout when fetching remote stylesheets (defaults to 5 seconds)', parseFloat)
3434
.option('--remove-inlined-files', 'Remove files inlined in <source-file ...> or via `@import` statements')
35-
.option('--skip-rebase', 'Disable URLs rebasing')
35+
.option('--with-rebase', 'Enable URLs rebasing')
3636
.option('--source-map', 'Enables building input\'s source map')
3737
.option('--source-map-inline-sources', 'Enables inlining sources inside source maps')
3838
.option('--input-source-map [file]', 'Specifies the path of the input source map file');
@@ -49,16 +49,17 @@ function cli(process, beforeMinifyCallback) {
4949
console.log(' %> cleancss --format keep-breaks one.css');
5050
console.log(' %> cleancss --format \'indentBy:1;indentWith:tab\' one.css');
5151
console.log(' %> cleancss --format \'breaks:afterBlockBegins=on;spaces:aroundSelectorRelation=on\' one.css');
52+
console.log(' %> cleancss --format \'breaks:afterBlockBegins=2;spaces:aroundSelectorRelation=on\' one.css');
5253
console.log(' %> # `breaks` controls where to insert breaks');
53-
console.log(' %> # `afterAtRule` controls if a line break comes after an at-rule; e.g. `@charset`; defaults to `off` (alias to `false`)');
54-
console.log(' %> # `afterBlockBegins` controls if a line break comes after a block begins; e.g. `@media`; defaults to `off`');
55-
console.log(' %> # `afterBlockEnds` controls if a line break comes after a block ends, defaults to `off`');
56-
console.log(' %> # `afterComment` controls if a line break comes after a comment; defaults to `off`');
57-
console.log(' %> # `afterProperty` controls if a line break comes after a property; defaults to `off`');
58-
console.log(' %> # `afterRuleBegins` controls if a line break comes after a rule begins; defaults to `off`');
59-
console.log(' %> # `afterRuleEnds` controls if a line break comes after a rule ends; defaults to `off`');
60-
console.log(' %> # `beforeBlockEnds` controls if a line break comes before a block ends; defaults to `off`');
61-
console.log(' %> # `betweenSelectors` controls if a line break comes between selectors; defaults to `off`');
54+
console.log(' %> # `afterAtRule` controls if a line break comes after an at-rule; e.g. `@charset`; defaults to `off` (alias to `false`); accepts number of line breaks as an argument too');
55+
console.log(' %> # `afterBlockBegins` controls if a line break comes after a block begins; e.g. `@media`; defaults to `off`; accepts number of line breaks as an argument too');
56+
console.log(' %> # `afterBlockEnds` controls if a line break comes after a block ends, defaults to `off`; accepts number of line breaks as an argument too');
57+
console.log(' %> # `afterComment` controls if a line break comes after a comment; defaults to `off`; accepts number of line breaks as an argument too');
58+
console.log(' %> # `afterProperty` controls if a line break comes after a property; defaults to `off`; accepts number of line breaks as an argument too');
59+
console.log(' %> # `afterRuleBegins` controls if a line break comes after a rule begins; defaults to `off`; accepts number of line breaks as an argument too');
60+
console.log(' %> # `afterRuleEnds` controls if a line break comes after a rule ends; defaults to `off`; accepts number of line breaks as an argument too');
61+
console.log(' %> # `beforeBlockEnds` controls if a line break comes before a block ends; defaults to `off`; accepts number of line breaks as an argument too');
62+
console.log(' %> # `betweenSelectors` controls if a line break comes between selectors; defaults to `off`; accepts number of line breaks as an argument too');
6263
console.log(' %> # `indentBy` controls number of characters to indent with; defaults to `0`');
6364
console.log(' %> # `indentWith` controls a character to indent with, can be `space` or `tab`; defaults to `space`');
6465
console.log(' %> # `spaces` controls where to insert spaces');
@@ -153,8 +154,8 @@ function cli(process, beforeMinifyCallback) {
153154
{ '0': commands.O0, '1': commands.O1, '2': commands.O2 } :
154155
undefined,
155156
output: commands.output,
156-
rebase: commands.skipRebase ? false : true,
157-
rebaseTo: ('output' in commands) && commands.output.length > 0 ? path.dirname(path.resolve(commands.output)) : process.cwd(),
157+
rebase: commands.withRebase ? true : false,
158+
rebaseTo: ('output' in commands) && commands.output.length > 0 ? path.dirname(path.resolve(commands.output)) : (commands.withRebase ? process.cwd() : undefined),
158159
sourceMap: commands.sourceMap,
159160
sourceMapInlineSources: commands.sourceMapInlineSources
160161
};

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
],
3434
"homepage": "https://github.com/jakubpawlowicz/clean-css-cli#readme",
3535
"dependencies": {
36-
"clean-css": "^4.2.1",
36+
"clean-css": "^5.0.1",
3737
"commander": "^2.20.3",
3838
"glob": "^7.1.6"
3939
},

test/binary-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ vows.describe('cleancss')
236236
'relative image paths': {
237237
'no output': binaryContext('./test/fixtures/partials-relative/base.css', {
238238
'should leave paths': function (error, stdout) {
239-
assert.equal(stdout, 'a{background:url(test/fixtures/partials/extra/down.gif) 0 0 no-repeat}');
239+
assert.equal(stdout, 'a{background:url(../partials/extra/down.gif) 0 0 no-repeat}');
240240
}
241241
}),
242242
'output': binaryContext('-o ./base1-min.css ./test/fixtures/partials-relative/base.css', {
@@ -269,14 +269,14 @@ vows.describe('cleancss')
269269
})
270270
.addBatch({
271271
'complex import and url rebasing': {
272-
'absolute': binaryContext('./test/fixtures/rebasing/assets/ui.css', {
272+
'absolute': binaryContext('--with-rebase ./test/fixtures/rebasing/assets/ui.css', {
273273
'should rebase urls correctly': function (error, stdout) {
274274
assert.include(stdout, 'url(test/fixtures/rebasing/components/bootstrap/images/glyphs.gif)');
275275
assert.include(stdout, 'url(test/fixtures/rebasing/components/jquery-ui/images/prev.gif)');
276276
assert.include(stdout, 'url(test/fixtures/rebasing/components/jquery-ui/images/next.gif)');
277277
}
278278
}),
279-
'relative': binaryContext('-o test/ui.bundled.css ./test/fixtures/rebasing/assets/ui.css', {
279+
'relative': binaryContext('--with-rebasing -o test/ui.bundled.css ./test/fixtures/rebasing/assets/ui.css', {
280280
'should rebase urls correctly': function () {
281281
var minimized = fs.readFileSync('test/ui.bundled.css', 'utf-8');
282282
assert.include(minimized, 'url(fixtures/rebasing/components/bootstrap/images/glyphs.gif)');
@@ -291,7 +291,7 @@ vows.describe('cleancss')
291291
})
292292
.addBatch({
293293
'complex import and skipped url rebasing': {
294-
'absolute': binaryContext('--skip-rebase ./test/fixtures/rebasing/assets/ui.css', {
294+
'absolute': binaryContext('./test/fixtures/rebasing/assets/ui.css', {
295295
'should rebase urls correctly': function (error, stdout) {
296296
assert.isNull(error);
297297
assert.include(stdout, 'url(../images/glyphs.gif)');
@@ -416,7 +416,7 @@ vows.describe('cleancss')
416416
}),
417417
'custom': pipedContext('div{width:0.00051px}', '-O1 roundingPrecision:4', {
418418
'should keep 4 decimal places': function (error, stdout) {
419-
assert.equal(stdout, 'div{width:.0005px}');
419+
assert.equal(stdout, 'div{width:0.0005px}');
420420
}
421421
}),
422422
'zero': pipedContext('div{width:1.5051px}', '-O1 roundingPrecision:0', {

test/custom-cli/custom-cleancss

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
#!/usr/bin/env node
22

33
var cleanCssCli = require('../../index');
4-
return cleanCssCli(process, function (cleanCss) {
5-
cleanCss.options.level['1'].transform = function (propertyName, propertyValue) {
6-
if (propertyName == 'background-image' && propertyValue.indexOf('../valid/path/to') == -1) {
7-
return propertyValue.replace('url(', 'url(../valid/path/to/');
4+
5+
var customPlugin = {
6+
level1: {
7+
value: function (propertyName, propertyValue, options) {
8+
if (propertyName == 'background-image' && propertyValue.indexOf('../valid/path/to') == -1) {
9+
return propertyValue.replace('url(', 'url(../valid/path/to/');
10+
} else {
11+
return propertyValue;
12+
}
813
}
914
}
15+
}
16+
17+
return cleanCssCli(process, function (cleanCss) {
18+
cleanCss.options.plugins.level1Value.push(customPlugin.level1.value);
1019
});

0 commit comments

Comments
 (0)