webpack-auto-inject-version/dist/components/inject-into-html.js

26 lines
937 B
JavaScript
Raw Normal View History

2016-10-20 17:58:19 +11:00
'use strict';
var InjectIntoHtml = (function () {
function InjectIntoHtml(context) {
this.context = context;
}
InjectIntoHtml.prototype.apply = function () {
var _this = this;
this.context.compiler.plugin('emit', function (compilation, cb) {
var _loop_1 = function() {
2016-10-20 19:32:26 +11:00
if (_this.context.options.injectIntoHtmlRegex.test(basename)) {
2016-10-20 17:58:19 +11:00
var asset = compilation.assets[basename];
var modFile_1 = asset.source().replace(/(\<\{version\}\>)/g, _this.context.version);
asset.source = function () { return modFile_1; };
}
};
for (var basename in compilation.assets) {
_loop_1();
}
cb();
});
2016-10-20 19:32:26 +11:00
return new Promise(function (resolve, reject) { resolve(); });
2016-10-20 17:58:19 +11:00
};
return InjectIntoHtml;
}());
module.exports = InjectIntoHtml;