Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
bower_components
package-lock.json
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 2.1.0 Updates
- Update `npm` modules
- Update `cave.js` to use latest dependencies
- Add option to API to compress output

# 2.0.0 Synchronous T-Rex

- Change public API to a synchronous one
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ npm test

MIT

[1]: https://github.com/pocketjoso/penthouse
[1]: https://github.com/pocketjoso/penthouse
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cave",
"description": "Remove critical CSS from your stylesheet after inlining it in your pages",
"version": "2.0.0",
"version": "2.1.0",
"homepage": "https://github.com/bevacqua/cave",
"author": {
"name": "Nicolas Bevacqua",
Expand All @@ -21,34 +21,34 @@
"test": "node test/cave"
},
"devDependencies": {
"browserify": "^4.2.1",
"browserify": "^16.2.3",
"contra": "^1.6.10",
"glob": "^4.0.6",
"gulp": "^3.6.2",
"gulp-bump": "~0.1.0",
"glob": "^7.1.4",
"gulp": "^4.0.2",
"gulp-bump": "^3.1.3",
"gulp-clean": "~0.2.3",
"gulp-concat": "~2.1.7",
"gulp-git": "~0.2.0",
"gulp-header": "^1.0.2",
"gulp-jshint": "~1.3.4",
"gulp-mocha": "~0.3.0",
"gulp-jshint": "^2.1.0",
"gulp-mocha": "^6.0.0",
"gulp-rename": "~0.2.2",
"gulp-size": "~0.1.1",
"gulp-streamify": "0.0.5",
"gulp-uglify": "~0.1.0",
"gulp-uglify": "^3.0.2",
"gzip-size": "^1.0.0",
"jshint": "~2.4.1",
"jshint": "^2.10.2",
"jshint-stylish": "~0.1.5",
"jshint-tap": "0.0.1",
"pretty-bytes": "^1.0.1",
"sizzle": "*",
"tape": "^3.0.0",
"tape": "^4.10.1",
"vinyl-source-stream": "^0.1.1"
},
"dependencies": {
"css": "^2.1.0",
"get-stdin": "^3.0.0",
"lodash": "^2.4.1",
"lodash": "^4.17.11",
"minimist": "^1.1.0"
}
}
7 changes: 4 additions & 3 deletions src/cave.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function api (stylesheet, options) {
var sheet = css.parse(read(stylesheet));
var sheetRules = sheet.stylesheet.rules;
var removables = css.parse(options.css);
var compressCss = options.compress;

removables.stylesheet.rules.forEach(inspectRule);
_.forEachRight(sheetRules, removeEmptyMedia);
Expand All @@ -23,8 +24,8 @@ function api (stylesheet, options) {
if (inspected.type === 'rule') {
if (parent) {
_(sheetRules)
.where({ type: 'media', media: parent.media })
.pluck('rules')
.filter({ type: 'media', media: parent.media })
.map('rules')
.value()
.forEach(removeMatches);
} else {
Expand Down Expand Up @@ -63,7 +64,7 @@ function api (stylesheet, options) {
}

function result () {
return css.stringify(sheet) + '\n';
return css.stringify(sheet, {compress: (compressCss == null || compressCss == undefined) ? true : compressCss ? true : false}) + '\n';
}
}

Expand Down