diff --git a/index.d.ts b/index.d.ts
new file mode 100644
index 0000000..6581b89
--- /dev/null
+++ b/index.d.ts
@@ -0,0 +1 @@
+declare module 'ejs-webpack-plugin';
diff --git a/index.js b/index.js
index df632c0..7858f1f 100644
--- a/index.js
+++ b/index.js
@@ -10,10 +10,10 @@ function makeTags(file, assets, type) {
if (i.substr(-4) !== '.map' && i.indexOf(file) !== -1) {
console.log(file, type, path.normalize(i), new RegExp(file).test(path.normalize(i)))
if (type === 'js' && /\.js/.test(path.normalize(i))) {
- tags += '';
+ tags += '';
- } else if (type === 'css' && new RegExp(file).test(path.normalize(i))) {
- tags += ''
+ } else if (type === 'css' && /\.css/.test(path.normalize(i))) {
+ tags += ''
}
}
})
@@ -50,7 +50,7 @@ function regReplace(origin, replaceContent, ref, type) {
}
EjsWebpackPlugin.prototype.ejsInject = function (assets , assets2 , assetTag , self) {
-
+
var entry = this.options.entry;
var ejsList = Object.keys(entry);
@@ -326,13 +326,12 @@ EjsWebpackPlugin.prototype.createHtmlTag = function (tagDefinition) {
EjsWebpackPlugin.prototype.apply = function (compiler) {
var _this = this
- compiler.plugin('emit', function (compilation, callback) {
-
+ compiler.hooks.emit.tapAsync('EjsWebpackPlugin', function (compilation, callback) {
var allChunks = compilation.getStats().toJson().chunks;
var chunks = _this.filterChunks(allChunks, _this.options.chunks, _this.options.excludeChunks);
var assets = _this.htmlWebpackPluginAssets(compilation, chunks);
var assetTags = _this.generateAssetTags(assets);
-
+
_this.ejsInject(Object.keys(compilation.assets) , assets , { body: assetTags.body, head: assetTags.head }, _this)
callback()