This commit is contained in:
2018-08-01 17:19:34 +02:00
parent c1f4678cfb
commit 6c081111c0
8175 changed files with 715546 additions and 6876 deletions
+20
View File
@@ -0,0 +1,20 @@
Copyright (c) 2017 scniro <scniro@outlook.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+79
View File
@@ -0,0 +1,79 @@
# 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)
[![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)
[![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)
## Regarding Issues
This is just a simple [gulp](https://github.com/gulpjs/gulp) plugin, which means it's nothing more than a thin wrapper around `clean-css`. If it looks like you are having CSS related issues, please contact [clean-css](https://github.com/jakubpawlowicz/clean-css/issues). Only create a new issue if it looks like you're having a problem with the plugin itself.
## Install
```
npm install gulp-clean-css --save-dev
```
## API
### cleanCSS([*options*], [*callback*])
#### options
See the [`CleanCSS` options](https://github.com/jakubpawlowicz/clean-css#how-to-use-clean-css-api).
```javascript
let gulp = require('gulp');
let cleanCSS = require('gulp-clean-css');
gulp.task('minify-css', () => {
return gulp.src('styles/*.css')
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('dist'));
});
```
#### callback
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
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
let gulp = require('gulp');
let cleanCSS = require('gulp-clean-css');
let sourcemaps = require('gulp-sourcemaps');
gulp.task('minify-css',() => {
return gulp.src('./src/*.css')
.pipe(sourcemaps.init())
.pipe(cleanCSS())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
```
## License
[MIT](./LICENSE) © 2017 [scniro](https://github.com/scniro)
+73
View File
@@ -0,0 +1,73 @@
'use strict';
const applySourceMap = require('vinyl-sourcemaps-apply');
const CleanCSS = require('clean-css');
const path = require('path');
const PluginError = require('plugin-error');
const through = require('through2');
module.exports = function gulpCleanCSS(options, callback) {
options = Object.assign(options || {});
if (arguments.length === 1 && Object.prototype.toString.call(arguments[0]) === '[object Function]')
callback = arguments[0];
let transform = function (file, enc, cb) {
if (!file || !file.contents)
return cb(null, file);
if (file.isStream()) {
this.emit('error', new PluginError('gulp-clean-css', 'Streaming not supported!'));
return cb(null, file);
}
if (file.sourceMap)
options.sourceMap = JSON.parse(JSON.stringify(file.sourceMap));
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(pass, function (errors, css) {
if (errors)
return cb(errors.join(' '));
if (typeof callback === 'function') {
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;
callback(details);
}
file.contents = new Buffer(css.styles);
if (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)
});
applySourceMap(file, map);
}
cb(null, file);
});
};
return through.obj(transform);
};
+89
View File
@@ -0,0 +1,89 @@
{
"_args": [
[
"gulp-clean-css@3.9.3",
"/mnt/data/Sites/r2c.net/user/themes/r2c"
]
],
"_development": true,
"_from": "gulp-clean-css@3.9.3",
"_id": "gulp-clean-css@3.9.3",
"_inBundle": false,
"_integrity": "sha512-mw5Qrio7W3rvswmVlZ7eaxOhBIp6zQMBFLgcHoi/xbOtaKT5zmElkHt8mvbRre7fMt5eLgppIkW+j9Cm+O/UqQ==",
"_location": "/gulp-clean-css",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "gulp-clean-css@3.9.3",
"name": "gulp-clean-css",
"escapedName": "gulp-clean-css",
"rawSpec": "3.9.3",
"saveSpec": null,
"fetchSpec": "3.9.3"
},
"_requiredBy": [
"#DEV:/"
],
"_resolved": "https://registry.npmjs.org/gulp-clean-css/-/gulp-clean-css-3.9.3.tgz",
"_spec": "3.9.3",
"_where": "/mnt/data/Sites/r2c.net/user/themes/r2c",
"author": {
"name": "scniro"
},
"bugs": {
"url": "https://github.com/scniro/gulp-clean-css/issues",
"email": "scniro@outlook.com"
},
"dependencies": {
"clean-css": "4.1.11",
"plugin-error": "1.0.1",
"through2": "2.0.3",
"vinyl-sourcemaps-apply": "0.2.1"
},
"description": "Minify css with clean-css.",
"devDependencies": {
"chai": "4.1.2",
"chai-string": "1.4.0",
"coveralls": "3.0.0",
"express": "4.16.2",
"fancy-log": "1.3.2",
"gulp": "3.9.1",
"gulp-concat": "2.6.1",
"gulp-istanbul": "1.1.3",
"gulp-mocha": "5.0.0",
"gulp-rename": "1.2.2",
"gulp-sass": "3.1.0",
"gulp-sourcemaps": "2.6.4",
"mocha": "5.0.4",
"vinyl": "2.1.0",
"vinyl-buffer": "1.0.1",
"vinyl-fs-fake": "1.1.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/scniro/gulp-clean-css#readme",
"keywords": [
"css",
"clean",
"minify",
"uglify",
"clean-css",
"minify-css",
"gulp-minify-css",
"gulp-clean-css",
"gulpplugin",
"gulpfriendly"
],
"license": "MIT",
"name": "gulp-clean-css",
"repository": {
"type": "git",
"url": "git+https://github.com/scniro/gulp-clean-css.git"
},
"scripts": {
"test": "gulp test"
},
"version": "3.9.3"
}