diff --git a/README.md b/README.md index 3e3dae8..fbcb64e 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,27 @@ Here's an example webpack config illustrating how to use these options: } ``` +Generating Multiple HTML Files +------------------------------ +To generate more than one HTML file, declare the plugin more than +once in your plugins array: +```javascript +{ + entry: 'index.js', + output: { + path: 'dist', + filename: 'index_bundle.js' + }, + plugins: [ + new HtmlWebpackPlugin(), // Generates default index.html + new HtmlWebpackPlugin({ // Also generate a test.html + filename: 'test.html', + template: 'src/assets/test.html' + }) + ] +} +``` + Writing Your Own Templates -------------------------- If the default generated HTML doesn't meet your needs you can supply @@ -100,7 +121,7 @@ HTML as well as the body. Your template might look like this: ``` -To use this template, simply configure the plugin like this: +To use this template, configure the plugin like this: ```javascript { entry: 'index.js', diff --git a/spec/HtmlWebpackPluginSpec.js b/spec/HtmlWebpackPluginSpec.js index 33b1a16..766d87b 100644 --- a/spec/HtmlWebpackPluginSpec.js +++ b/spec/HtmlWebpackPluginSpec.js @@ -4,7 +4,7 @@ var webpack = require('webpack'); var rm_rf = require('rimraf'); var HtmlWebpackPlugin = require('../index.js'); -var OUTPUT_DIR = path.join(__dirname, '..', 'dist'); +var OUTPUT_DIR = path.join(__dirname, '../dist'); function testHtmlPlugin(webpackConfig, expectedResults, done, outputFile) { outputFile = outputFile || 'index.html'; @@ -31,7 +31,7 @@ describe('HtmlWebpackPlugin', function() { it('generates a default index.html file for a single entry point', function(done) { testHtmlPlugin({ - entry: path.join(__dirname, 'fixtures', 'index.js'), + entry: path.join(__dirname, 'fixtures/index.js'), output: { path: OUTPUT_DIR, filename: 'index_bundle.js' @@ -44,8 +44,8 @@ describe('HtmlWebpackPlugin', function() { it('generates a default index.html file with multiple entry points', function(done) { testHtmlPlugin({ entry: { - util: path.join(__dirname, 'fixtures', 'util.js'), - app: path.join(__dirname, 'fixtures', 'index.js') + util: path.join(__dirname, 'fixtures/util.js'), + app: path.join(__dirname, 'fixtures/index.js') }, output: { path: OUTPUT_DIR, @@ -58,13 +58,13 @@ describe('HtmlWebpackPlugin', function() { it('allows you to specify your own HTML template', function(done) { testHtmlPlugin({ entry: { - app: path.join(__dirname, 'fixtures', 'index.js') + app: path.join(__dirname, 'fixtures/index.js') }, output: { path: OUTPUT_DIR, filename: '[name]_bundle.js' }, - plugins: [new HtmlWebpackPlugin({template: path.join(__dirname, 'fixtures', 'test.html')})] + plugins: [new HtmlWebpackPlugin({template: path.join(__dirname, 'fixtures/test.html')})] }, ['