-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (26 loc) · 932 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
var gutil = require('gulp-util');
var through = require('through2');
var cheerio = require('cheerio');
var fs = require('fs');
var path = require('path');
var mime = require('mime');
module.exports = function() {
// create a stream through which each file will pass
return through.obj(function(file, enc, callback) {
if (file.isNull()) {
this.push(file);
// do nothing if no contents
return callback();
}
if (file.isStream()) {
this.emit('error', new gutil.PluginError('gulp-file64', 'Streaming not supported'));
return callback();
}
if (file.isBuffer()) {
var simg64 = new Buffer(String(file.contents).replace('../css/app.css','').replace(/<#/g, '<#').replace(/></g, '><').replace(/>/g, '>').replace(/<\/\#/g, '</#').replace(/=/g, '=').replace(/"/g, '"')).toString('base64');
file.contents = new Buffer(simg64);
return callback(null, file);
}
});
};