diff --git a/index.js b/index.js index a8fde22..efcfd6a 100644 --- a/index.js +++ b/index.js @@ -8,8 +8,8 @@ function HtmlWebpackPlugin(options) { HtmlWebpackPlugin.prototype.apply = function(compiler) { var self = this; - compiler.plugin('done', function(stats) { - var webpackStatsJson = stats.toJson(); + compiler.plugin('after-emit', function(compiler, callback) { + var webpackStatsJson = compiler.getStats().toJson(); var templateParams = {}; templateParams.webpack = webpackStatsJson; templateParams.htmlWebpackPlugin = {}; @@ -20,8 +20,11 @@ HtmlWebpackPlugin.prototype.apply = function(compiler) { if (!templateFile) { templateFile = path.join(__dirname, 'default_index.html'); } + var htmlTemplateContent = fs.readFileSync(templateFile, 'utf8'); - fs.writeFileSync(path.join(compiler.options.output.path, 'index.html'), tmpl(htmlTemplateContent, templateParams)); + var html = tmpl(htmlTemplateContent, templateParams); + var outputPath = path.join(compiler.options.output.path, 'index.html'); + this.outputFileSystem.writeFile(outputPath, html, callback); }); }; diff --git a/package.json b/package.json index 5e03ac7..57f9c8f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "html-webpack-plugin", - "version": "0.1.0", - "description": "Generates HTML files to serve your webpack bundles", + "version": "0.2.0", + "description": "Simplifies creation of HTML files to serve your webpack bundles", "main": "index.js", "scripts": { "test": "node_modules/.bin/jshint *.js spec && node_modules/.bin/jasmine-node --captureExceptions spec" diff --git a/spec/HtmlWebpackPluginSpec.js b/spec/HtmlWebpackPluginSpec.js index 529e05b..4739607 100644 --- a/spec/HtmlWebpackPluginSpec.js +++ b/spec/HtmlWebpackPluginSpec.js @@ -113,7 +113,9 @@ describe('HtmlWebpackPlugin', function() { }, plugins: [new HtmlWebpackPlugin()] }, ['