forked from zont/gulp-usemin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
24 lines (23 loc) · 747 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
module.exports = function(options) {
var through = require('through2');
var gutil = require('gulp-util');
var blocksBuilder = require('./lib/blocksBuilder.js');
var htmlBuilder = require('./lib/htmlBuilder.js');
return through.obj(function(file, enc, callback) {
if (file.isStream()) {
this.emit('error', new gutil.PluginError('gulp-usemin', 'Streams are not supported!'));
callback();
}
else if (file.isNull())
callback(null, file); // Do nothing if no contents
else {
try {
var blocks = blocksBuilder(file, options);
htmlBuilder(file, blocks, options, this.push.bind(this), callback);
} catch(e) {
this.emit('error', e);
callback();
}
}
});
};