Skip to content
This repository was archived by the owner on Sep 5, 2022. It is now read-only.

Commit ea08363

Browse files
author
Mehdy Dara
committed
Update README.md, and version
1 parent ce990ca commit ea08363

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ gulp.task('default', function () {
4242
gulp.task('default', function () {
4343
return gulp.src('src/css/input.css')
4444
.pipe(cssBase64({
45+
verbose: true
4546
baseDir: "../../images",
4647
maxWeightResource: 100,
4748
extensionsAllowed: ['.gif', '.jpg']
@@ -60,10 +61,33 @@ Default value: `false`
6061
Note: Writes in stdout for more infos on process. (Resource ignored, fetch remote resource, etc)
6162

6263
#### options.preProcess
63-
Type: `Function(buffer, mimeType, callback)`
64+
Type: `Function(vinylFile, callback)`
6465

6566
Default value: ``
6667

68+
Note: Vinyl is a virtual file format. See [description](https://github.com/wearefractal/vinyl#file)
69+
70+
Example:
71+
```js
72+
// Apply a rotation on each PNG image with NPM library http://aheckmann.github.io/gm/
73+
var gm = require('gm').subClass({
74+
imageMagick: true
75+
});
76+
[...]
77+
.pipe(cssBase64({
78+
preProcess : function(vinylFile, callback) {
79+
if ('image/png' === mime.lookup(vinylFile.path)) {
80+
gm(vinylFile.path).rotate('green', 180).toBuffer(function (err, buffer) {
81+
vinylFile.contents = buffer;
82+
return callback(vinylFile);
83+
})
84+
}
85+
}
86+
}))
87+
[...]
88+
89+
```
90+
6791
#### options.baseDir
6892
Type: `String`
6993

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gulp-css-base64",
33
"description": "Gulp's task for transform all resources found in a CSS into base64-encoded data URI strings",
4-
"version": "1.2.2",
4+
"version": "1.2.3",
55
"homepage": "http://github.com/zckrs/gulp-css-base64",
66
"repository": {
77
"type": "git",

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function gulpCssBase64(opts) {
6363
}
6464

6565
if (opts.extensionsAllowed.length !== 0 && opts.extensionsAllowed.indexOf(path.extname(result[1])) == -1) {
66-
log("Ignore " + chalk.yellow(result[1]) + ", extension not allowed " + chalk.yellow(path.extname(result[1])), opts.verbose);
66+
log("Ignores " + chalk.yellow(result[1]) + ", extension not allowed " + chalk.yellow(path.extname(result[1])), opts.verbose);
6767
callback();
6868
return;
6969
}
@@ -72,7 +72,7 @@ function gulpCssBase64(opts) {
7272
if (undefined !== fileRes) {
7373

7474
if (fileRes.contents.length > opts.maxWeightResource) {
75-
log("Ignore " + chalk.yellow(result[1]) + ", file is too big " + chalk.yellow(fileRes.contents.length + " bytes"), opts.verbose);
75+
log("Ignores " + chalk.yellow(result[1]) + ", file is too big " + chalk.yellow(fileRes.contents.length + " bytes"), opts.verbose);
7676
callback();
7777
return;
7878
}
@@ -113,13 +113,13 @@ function encodeResource(img, file, opts, doneCallback) {
113113
var fileRes = new gutil.File();
114114

115115
if (/^data:/.test(img)) {
116-
log("Ignore " + chalk.yellow(img.substring(0, 30) + '...') + ", already encoded", opts.verbose);
116+
log("Ignores " + chalk.yellow(img.substring(0, 30) + '...') + ", already encoded", opts.verbose);
117117
doneCallback();
118118
return;
119119
}
120120

121121
if (img[0] === '#') {
122-
log("Ignore " + chalk.yellow(img.substring(0, 30) + '...') + ", SVG mask", opts.verbose);
122+
log("Ignores " + chalk.yellow(img.substring(0, 30) + '...') + ", SVG mask", opts.verbose);
123123
doneCallback();
124124
return;
125125
}

0 commit comments

Comments
 (0)