Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: scniro/gulp-clean-css
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c272eac332be81f0b2c13cbb22d4fabcd9692fa5
Choose a base ref
...
head repository: scniro/gulp-clean-css
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e2bf4d27b241ccee116ceff00515295532156fde
Choose a head ref

Commits on May 7, 2017

  1. Copy the full SHA
    9ca15f2 View commit details
  2. use strict for let support

    scniro committed May 7, 2017
    Copy the full SHA
    b701c36 View commit details
  3. bump 3.1.1

    scniro committed May 7, 2017
    Copy the full SHA
    0abeca5 View commit details

Commits on May 8, 2017

  1. update dep, clean-css 4.1.1

    Sal Niro committed May 8, 2017
    Copy the full SHA
    38b8899 View commit details

Commits on May 15, 2017

  1. rebasing, clean-css 4.1.2

    scniro committed May 15, 2017
    Copy the full SHA
    92ddf63 View commit details
  2. Merge remote-tracking branch 'origin/master'

    # Conflicts:
    #	package.json
    scniro committed May 15, 2017
    Copy the full SHA
    81d70a7 View commit details
  3. bump 3.3.0

    scniro committed May 15, 2017
    Copy the full SHA
    0efd1c3 View commit details

Commits on May 16, 2017

  1. #42

    scniro committed May 16, 2017
    Copy the full SHA
    ba2ee13 View commit details

Commits on May 21, 2017

  1. pass rebase option

    Sal Niro committed May 21, 2017
    Copy the full SHA
    eeee392 View commit details

Commits on May 22, 2017

  1. Copy the full SHA
    5dc705c View commit details

Commits on May 31, 2017

  1. Copy the full SHA
    f389d8f View commit details
  2. bump

    scniro committed May 31, 2017
    Copy the full SHA
    d6729f2 View commit details

Commits on Jun 14, 2017

  1. clean-css => 4.1.4, dep updates

    Sal Niro committed Jun 14, 2017
    Copy the full SHA
    414e7cb View commit details
  2. slight cleanup

    Sal Niro committed Jun 14, 2017
    Copy the full SHA
    8709c50 View commit details
  3. build, node v8

    Sal Niro committed Jun 14, 2017
    Copy the full SHA
    bc636fc View commit details
  4. dm, readme

    Sal Niro committed Jun 14, 2017
    Copy the full SHA
    c93de53 View commit details
  5. readme

    Sal Niro committed Jun 14, 2017
    Copy the full SHA
    6db6e08 View commit details

Commits on Jun 29, 2017

  1. bump to clean-css 4.1.5

    scniro committed Jun 29, 2017
    Copy the full SHA
    edd64a9 View commit details

Commits on Jul 8, 2017

  1. clean-css bump

    scniro committed Jul 8, 2017
    Copy the full SHA
    4a4daa1 View commit details

Commits on Jul 11, 2017

  1. 😎

    scniro committed Jul 11, 2017
    Copy the full SHA
    a43222d View commit details
  2. link fix for badge

    scniro committed Jul 11, 2017
    Copy the full SHA
    47425a2 View commit details

Commits on Jul 14, 2017

  1. bump clean-css 4-1-7

    scniro committed Jul 14, 2017
    Copy the full SHA
    2f70027 View commit details

Commits on Sep 4, 2017

  1. clean-css => 4.1.8

    scniro committed Sep 4, 2017
    Copy the full SHA
    e6c44e4 View commit details

Commits on Sep 19, 2017

  1. clean-css => 4.1.9

    scniro committed Sep 19, 2017
    Copy the full SHA
    869e147 View commit details

Commits on Nov 17, 2017

  1. readme syntax consistency

    scniro committed Nov 17, 2017
    Copy the full SHA
    9f5c4ab View commit details

Commits on Dec 28, 2017

  1. removed deprecated gulp-util (#50)

    zbennett10 authored and scniro committed Dec 28, 2017
    Copy the full SHA
    48e956f View commit details
  2. dep updates, test cleanup

    scniro committed Dec 28, 2017
    Copy the full SHA
    e2bf4d2 View commit details
Showing with 5,580 additions and 420 deletions.
  1. +2 −17 .travis.yml
  2. +26 −24 README.md
  3. +9 −9 gulpfile.js
  4. +14 −8 index.js
  5. +5,296 −0 package-lock.json
  6. +22 −22 package.json
  7. +211 −340 test/test.js
19 changes: 2 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
language: node_js
node_js:
- "7.5"
- "7.4"
- "7.3"
- "7.2"
- "7.1"
- "9"
- "8"
- "7"
- "6.9"
- "6.8"
- "6.7"
- "6.6"
- "6.5"
- "6.4"
- "6.3"
- "6.2"
- "6"
- "5"
- "5.1"
- "4"
- "4.2"
- "4.1"
- "4.0"
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# gulp-clean-css

[![Build Status](https://img.shields.io/travis/scniro/gulp-clean-css.svg?style=flat-square)](https://travis-ci.org/scniro/gulp-clean-css)
[![NPM Version](https://img.shields.io/npm/v/gulp-clean-css.svg?style=flat-square)](https://www.npmjs.com/package/gulp-clean-css)
[![Dependency Status](https://img.shields.io/david/scniro/gulp-clean-css.svg?label=deps&style=flat-square)](https://david-dm.org/scniro/gulp-clean-css)
[![devDependency Status](https://img.shields.io/david/dev/scniro/gulp-clean-css.svg?label=devDeps&style=flat-square)](https://david-dm.org/scniro/gulp-clean-css#info=devDependencies)
[![Coverage](https://img.shields.io/coveralls/scniro/gulp-clean-css.svg?style=flat-square)](https://coveralls.io/github/scniro/gulp-clean-css)
[![Climate](https://img.shields.io/codeclimate/github/scniro/gulp-clean-css.svg?label=climate&style=flat-square)](https://codeclimate.com/github/scniro/gulp-clean-css)
[![Downloads](https://img.shields.io/npm/dm/gulp-clean-css.svg?style=flat-square)](https://www.npmjs.com/package/gulp-clean-css)
[![NPM Version](https://img.shields.io/npm/v/gulp-clean-css.svg?style=flat-square)](https://www.npmjs.com/package/gulp-clean-css)
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/alferov/awesome-gulp#minification)

> [gulp](http://gulpjs.com/) plugin to minify CSS, using [clean-css](https://github.com/jakubpawlowicz/clean-css)
@@ -28,10 +30,10 @@ npm install gulp-clean-css --save-dev
See the [`CleanCSS` options](https://github.com/jakubpawlowicz/clean-css#how-to-use-clean-css-api).

```javascript
var gulp = require('gulp');
var cleanCSS = require('gulp-clean-css');
let gulp = require('gulp');
let cleanCSS = require('gulp-clean-css');

gulp.task('minify-css', function() {
gulp.task('minify-css', () => {
return gulp.src('styles/*.css')
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('dist'));
@@ -43,36 +45,36 @@ gulp.task('minify-css', function() {
Useful for returning details from the underlying [`minify()`](https://github.com/jakubpawlowicz/clean-css#using-api) call. An example use case could include logging `stats` of the minified file. In addition to the default object, `gulp-clean-css` provides the file `name` and `path` for further analysis.

```javascript
var gulp = require('gulp');
var cleanCSS = require('gulp-clean-css');

gulp.task('minify-css', function() {
return gulp.src('styles/*.css')
.pipe(cleanCSS({debug: true}, function(details) {
console.log(details.name + ': ' + details.stats.originalSize);
console.log(details.name + ': ' + details.stats.minifiedSize);
}))
.pipe(gulp.dest('dist'));
let gulp = require('gulp');
let cleanCSS = require('gulp-clean-css');

gulp.task('minify-css', () => {
return gulp.src('styles/*.css')
.pipe(cleanCSS({debug: true}, (details) => {
console.log(`${details.name}: ${details.stats.originalSize}`);
console.log(`${details.name}: ${details.stats.minifiedSize}`);
}))
.pipe(gulp.dest('dist'));
});
```

[Source Maps](http://www.html5rocks.com/tutorials/developertools/sourcemaps/) can be generated by using [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps).

```javascript

var gulp = require('gulp');
var cleanCSS = require('gulp-clean-css');
var sourcemaps = require('gulp-sourcemaps');
let gulp = require('gulp');
let cleanCSS = require('gulp-clean-css');
let sourcemaps = require('gulp-sourcemaps');

gulp.task('minify-css', function() {
return gulp.src('./src/*.css')
.pipe(sourcemaps.init())
.pipe(cleanCSS())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
gulp.task('minify-css',() => {
return gulp.src('./src/*.css')
.pipe(sourcemaps.init())
.pipe(cleanCSS())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
```

## License

[MIT](./LICENSE) © 2016 [scniro](https://github.com/scniro)
[MIT](./LICENSE) © 2017 [scniro](https://github.com/scniro)
18 changes: 9 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var gutil = require('gulp-util');
var log = require('fancy-log');
var istanbul = require('gulp-istanbul');

gulp.task('pre-test', function () {
return gulp.src(['index.js'])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});

gulp.task('test', ['pre-test'], function () {
return gulp.src('test/*.js')
.pipe(mocha({reporter: 'list'}))
.pipe(istanbul.writeReports({
includeUntested: true,
reporters: ['lcov']
}))
.on('error', gutil.log);
.pipe(mocha({reporter: 'dot'}))
.pipe(istanbul.writeReports({
includeUntested: true,
reporters: ['lcov']
}))
.on('error', log);
});
22 changes: 14 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
'use strict';

const applySourceMap = require('vinyl-sourcemaps-apply');
const CleanCSS = require('clean-css');
const path = require('path');
const PluginError = require('gulp-util').PluginError;
const PluginError = require('plugin-error');
const through = require('through2');

module.exports = function gulpCleanCSS(options, callback) {

options = options || {};
options = Object.assign(options || {});

if (arguments.length === 1 && Object.prototype.toString.call(arguments[0]) === '[object Function]')
callback = arguments[0];

var transform = function (file, enc, cb) {
let transform = function (file, enc, cb) {

if (!file || !file.contents)
return cb(null, file);
@@ -24,21 +26,25 @@ module.exports = function gulpCleanCSS(options, callback) {
if (file.sourceMap)
options.sourceMap = JSON.parse(JSON.stringify(file.sourceMap));

var style = file.contents ? file.contents.toString() : '';
let contents = file.contents ? file.contents.toString() : '';
let pass = {[file.path]: {styles: contents}};
if (!options.rebaseTo && options.rebase !== false) {
options.rebaseTo = path.dirname(file.path);
}

new CleanCSS(options).minify(style, function (errors, css) {
new CleanCSS(options).minify(pass, function (errors, css) {

if (errors)
return cb(errors.join(' '));

if (typeof callback === 'function') {
var details = {
let details = {
'stats': css.stats,
'errors': css.errors,
'warnings': css.warnings,
'path': file.path,
'name': file.path.split(file.base)[1]
}
};

if (css.sourceMap)
details['sourceMap'] = css.sourceMap;
@@ -50,7 +56,7 @@ module.exports = function gulpCleanCSS(options, callback) {

if (css.sourceMap) {

var map = JSON.parse(css.sourceMap);
let map = JSON.parse(css.sourceMap);
map.file = path.relative(file.base, file.path);
map.sources = map.sources.map(function (src) {
return path.relative(file.base, file.path)
Loading