Skip to content

Commit aeea32e

Browse files
committed
Merge pull request #34 from wenbing/master
Remove wrapped browerify bundle function
2 parents c19c613 + e3d2251 commit aeea32e

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

index.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ module.exports = function (browserify, options) {
102102
self.queue(output);
103103
self.queue(null);
104104
}, function (err) {
105-
console.error('loader err', err);
105+
browserify.emit('error', err);
106106
});
107107
});
108108
}
@@ -111,27 +111,24 @@ module.exports = function (browserify, options) {
111111
global: true
112112
});
113113

114-
// wrap the `bundle` function
115-
var bundle = browserify.bundle;
116-
browserify.bundle = function (cb) {
117-
// reset the `tokensByFile` cache
118-
tokensByFile = {};
114+
browserify.on('bundle', function(bundle) {
115+
bundle.on('end', function() {
116+
// reset the `tokensByFile` cache
117+
tokensByFile = {};
119118

120-
// call the original
121-
var stream = bundle.call(browserify, function () {
122119
// Combine the collected sources into a single CSS file
123120
var css = Object.keys(sourceByFile).map(function(file) {
124121
return sourceByFile[file];
125122
}).join('\n');
126123
var args = arguments;
127124

128-
fs.writeFile(cssOutFilename, css, function () {
129-
if (typeof cb === 'function') cb.apply(null, args);
125+
fs.writeFile(cssOutFilename, css, function (err) {
126+
if (err) {
127+
browserify.emit('error', err);
128+
}
130129
});
131130
});
132-
133-
return stream;
134-
};
131+
});
135132

136133
return browserify;
137134
};

0 commit comments

Comments
 (0)