diff --git a/index.js b/index.js index efcfd6a..ebc0308 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ function HtmlWebpackPlugin(options) { HtmlWebpackPlugin.prototype.apply = function(compiler) { var self = this; - compiler.plugin('after-emit', function(compiler, callback) { + compiler.plugin('emit', function(compiler, callback) { var webpackStatsJson = compiler.getStats().toJson(); var templateParams = {}; templateParams.webpack = webpackStatsJson; @@ -24,7 +24,15 @@ HtmlWebpackPlugin.prototype.apply = function(compiler) { var htmlTemplateContent = fs.readFileSync(templateFile, 'utf8'); var html = tmpl(htmlTemplateContent, templateParams); var outputPath = path.join(compiler.options.output.path, 'index.html'); - this.outputFileSystem.writeFile(outputPath, html, callback); + compiler.assets['index.html'] = { + source: function() { + return html; + }, + size: function() { + return html.length; + } + }; + callback(); }); }; diff --git a/spec/fixtures/index.js b/spec/fixtures/index.js index b413572..95d7b8f 100644 --- a/spec/fixtures/index.js +++ b/spec/fixtures/index.js @@ -1 +1 @@ -document.body.textContent = helloText(); +document.body.innerHTML = document.body.innerHTML + "
index.js
"; diff --git a/spec/fixtures/util.js b/spec/fixtures/util.js index 1e469c1..999021e 100644 --- a/spec/fixtures/util.js +++ b/spec/fixtures/util.js @@ -1,3 +1 @@ -function helloText() { - return "Hello world"; -} +document.body.innerHTML = document.body.innerHTML + "util.js
";