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

25 lines
840 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() {
if (/^index\.html$/.test(basename)) {
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();
});
};
return InjectIntoHtml;
}());
module.exports = InjectIntoHtml;