Skip to content

Commit 8d1978e

Browse files
author
李昕亮
committed
add callback
add callback
1 parent 624b082 commit 8d1978e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

html-inline-source-webpack-plugin.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,33 @@ function inline ( file, option ) {
2828
fs.writeFileSync(file, inlineSource.sync(file, option));
2929
}
3030

31-
function HtmlInlineSourceWebpackPlugin ( configs ) {
31+
function HtmlInlineSourceWebpackPlugin ( configs, callback ) {
3232
if (!(this instanceof HtmlInlineSourceWebpackPlugin)) {
3333
throw 'Cannot call HtmlInlineSourceWebpackPlugin as a function.';
3434
}
35-
if (typeof configs !== 'object') {
35+
if (typeof configs == 'function') {
36+
callback = configs;
37+
configs = {};
38+
}
39+
if (typeof configs != 'object') {
3640
configs = {};
3741
}
3842
if (configs instanceof Array) {
3943
this.configs = configs;
4044
} else {
4145
this.configs = [configs];
4246
}
47+
if (typeof callback == 'function') {
48+
this.callback = callback;
49+
} else {
50+
this.callback = function () {};
51+
}
4352
}
4453

4554
HtmlInlineSourceWebpackPlugin.prototype.apply = function ( compiler ) {
4655
var configs = this.configs;
4756
var length = configs.length;
57+
var callback = this.callback;
4858
compiler.plugin('done', function ( stats ) {
4959
var compiler = stats.compilation.compiler;
5060
var outputPath = path.join(compiler.context, compiler.outputPath);
@@ -93,6 +103,7 @@ HtmlInlineSourceWebpackPlugin.prototype.apply = function ( compiler ) {
93103
}
94104
}
95105
});
106+
callback();
96107
});
97108
};
98109

0 commit comments

Comments
 (0)