diff --git a/examples/two-loaders/partial.html b/examples/custom-template/partial.html similarity index 100% rename from examples/two-loaders/partial.html rename to examples/custom-template/partial.html diff --git a/examples/custom-template/readme.md b/examples/custom-template/readme.md new file mode 100644 index 0000000..5c00e6f --- /dev/null +++ b/examples/custom-template/readme.md @@ -0,0 +1,4 @@ +# custom template + +This example uses a custom underscore template which inlines an partial using the html-loader: +`<%= require('html!./partial.html') %>` \ No newline at end of file diff --git a/examples/custom-template/template.html b/examples/custom-template/template.html index b7b4f97..0e33b24 100644 --- a/examples/custom-template/template.html +++ b/examples/custom-template/template.html @@ -2,10 +2,10 @@ - Example template + <%= htmlWebpackPlugin.options.title %> - + <%= require('html!./partial.html') %> \ No newline at end of file diff --git a/examples/default/readme.md b/examples/default/readme.md new file mode 100644 index 0000000..8e9aa8f --- /dev/null +++ b/examples/default/readme.md @@ -0,0 +1,3 @@ +# zero-config example + +in this example only the default configuration is used \ No newline at end of file diff --git a/examples/jade-loader/example.js b/examples/jade-loader/example.js index 13a1ca1..6f4a05b 100755 --- a/examples/jade-loader/example.js +++ b/examples/jade-loader/example.js @@ -1,4 +1,10 @@ +'use strict'; require('./main.css'); -var h1 = document.createElement('h1'); -h1.innerHTML = 'Hello world!'; -document.body.appendChild(h1); \ No newline at end of file +// Use the same template for the frontend code +var template = require('./time.jade'); + +setInterval(function() { + var div = document.getElementById('main'); + div.innerHTML = template({ time: new Date()}); + div.style.color = 'navy'; +}, 1000); \ No newline at end of file diff --git a/examples/jade-loader/readme.md b/examples/jade-loader/readme.md new file mode 100644 index 0000000..1d58a19 --- /dev/null +++ b/examples/jade-loader/readme.md @@ -0,0 +1,4 @@ +# isomorphic jade example + +This example shows how to use a different template engine (in this case jade) +to load the `time.jade` template on the backend and frontend. diff --git a/examples/jade-loader/template.jade b/examples/jade-loader/template.jade index 9341773..47a4be2 100644 --- a/examples/jade-loader/template.jade +++ b/examples/jade-loader/template.jade @@ -1,5 +1,8 @@ doctype html html head - title my jade template - body \ No newline at end of file + title= htmlWebpackPlugin.options.title + body + #main + - locals.time = new Date(); + include ./time.jade \ No newline at end of file diff --git a/examples/jade-loader/time.jade b/examples/jade-loader/time.jade new file mode 100644 index 0000000..7dfa94b --- /dev/null +++ b/examples/jade-loader/time.jade @@ -0,0 +1,6 @@ +// this partial is used for frontend and backend +.time + b Current time + p #{time.toTimeString()} + +img(src="#{require('./logo.png')}") \ No newline at end of file diff --git a/examples/jade-loader/webpack.config.js b/examples/jade-loader/webpack.config.js index 4e097f8..3786711 100755 --- a/examples/jade-loader/webpack.config.js +++ b/examples/jade-loader/webpack.config.js @@ -16,9 +16,10 @@ module.exports = { }, plugins: [ new HtmlWebpackPlugin({ - filename: 'jade-loader.html', + filename: 'index.html', favicon: 'favicon.ico', - template: 'template.jade' + template: 'template.jade', + title: 'Jade demo' }), new ExtractTextPlugin('styles.css') ] diff --git a/examples/javascript/example.js b/examples/javascript/example.js index 8b8f606..5b71c95 100644 --- a/examples/javascript/example.js +++ b/examples/javascript/example.js @@ -1,4 +1,7 @@ require('./main.css'); + +var universal = require('./universial.js'); var h1 = document.createElement('h1'); -h1.innerHTML = 'Hello world'; +h1.innerHTML = universal(); + document.body.appendChild(h1); \ No newline at end of file diff --git a/examples/javascript/readme.md b/examples/javascript/readme.md new file mode 100644 index 0000000..5866653 --- /dev/null +++ b/examples/javascript/readme.md @@ -0,0 +1,3 @@ +# isomorphic javascript example + +This example shows how to generate a template on the fly using javascript. \ No newline at end of file diff --git a/examples/javascript/template.js b/examples/javascript/template.js index d6c1c33..153d654 100644 --- a/examples/javascript/template.js +++ b/examples/javascript/template.js @@ -1,5 +1,6 @@ // Webpack require: var partial = require('./partial.html'); +var universal = require('./universial.js'); // Export a function / promise / or a string: -module.exports = new Date() + partial; +module.exports = universal() + new Date() + partial; diff --git a/examples/javascript/universial.js b/examples/javascript/universial.js new file mode 100644 index 0000000..58b8872 --- /dev/null +++ b/examples/javascript/universial.js @@ -0,0 +1,5 @@ +// This file is used for frontend and backend +'use strict'; +module.exports = function() { + return "Hello World"; +}; \ No newline at end of file diff --git a/examples/two-loaders/example.js b/examples/two-loaders/example.js deleted file mode 100755 index 13a1ca1..0000000 --- a/examples/two-loaders/example.js +++ /dev/null @@ -1,4 +0,0 @@ -require('./main.css'); -var h1 = document.createElement('h1'); -h1.innerHTML = 'Hello world!'; -document.body.appendChild(h1); \ No newline at end of file diff --git a/examples/two-loaders/logo.png b/examples/two-loaders/logo.png deleted file mode 100644 index d71b3d7..0000000 Binary files a/examples/two-loaders/logo.png and /dev/null differ diff --git a/examples/two-loaders/main.css b/examples/two-loaders/main.css deleted file mode 100644 index 232a2cd..0000000 --- a/examples/two-loaders/main.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - background: snow; -} \ No newline at end of file diff --git a/examples/two-loaders/template.html b/examples/two-loaders/template.html deleted file mode 100644 index edb44d6..0000000 --- a/examples/two-loaders/template.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Example template - - - - <%= require('html!./partial.html') %> - - \ No newline at end of file diff --git a/examples/two-loaders/two-loaders/example.js b/examples/two-loaders/two-loaders/example.js deleted file mode 100644 index 13a1ca1..0000000 --- a/examples/two-loaders/two-loaders/example.js +++ /dev/null @@ -1,4 +0,0 @@ -require('./main.css'); -var h1 = document.createElement('h1'); -h1.innerHTML = 'Hello world!'; -document.body.appendChild(h1); \ No newline at end of file diff --git a/examples/two-loaders/two-loaders/logo.png b/examples/two-loaders/two-loaders/logo.png deleted file mode 100644 index d71b3d7..0000000 Binary files a/examples/two-loaders/two-loaders/logo.png and /dev/null differ diff --git a/examples/two-loaders/two-loaders/main.css b/examples/two-loaders/two-loaders/main.css deleted file mode 100644 index 232a2cd..0000000 --- a/examples/two-loaders/two-loaders/main.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - background: snow; -} \ No newline at end of file diff --git a/examples/two-loaders/two-loaders/partial.html b/examples/two-loaders/two-loaders/partial.html deleted file mode 100644 index 47dc0f7..0000000 --- a/examples/two-loaders/two-loaders/partial.html +++ /dev/null @@ -1,2 +0,0 @@ -

Partial

- \ No newline at end of file diff --git a/examples/two-loaders/two-loaders/template.html b/examples/two-loaders/two-loaders/template.html deleted file mode 100644 index edb44d6..0000000 --- a/examples/two-loaders/two-loaders/template.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Example template - - - - <%= require('html!./partial.html') %> - - \ No newline at end of file diff --git a/examples/two-loaders/two-loaders/webpack.config.js b/examples/two-loaders/two-loaders/webpack.config.js deleted file mode 100644 index 7df9d54..0000000 --- a/examples/two-loaders/two-loaders/webpack.config.js +++ /dev/null @@ -1,22 +0,0 @@ -var HtmlWebpackPlugin = require('../..'); -var ExtractTextPlugin = require('extract-text-webpack-plugin'); -module.exports = { - entry: './example.js', - output: { - path: __dirname + '/dist', - publicPath: '', - filename: 'bundle.js' - }, - module: { - loaders: [ - { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') }, - { test: /\.png$/, loader: 'file-loader' } - ] - }, - plugins: [ - new HtmlWebpackPlugin({ - template: 'template.html' - }), - new ExtractTextPlugin('styles.css') - ] -}; \ No newline at end of file diff --git a/examples/two-loaders/webpack.config.js b/examples/two-loaders/webpack.config.js deleted file mode 100755 index 7df9d54..0000000 --- a/examples/two-loaders/webpack.config.js +++ /dev/null @@ -1,22 +0,0 @@ -var HtmlWebpackPlugin = require('../..'); -var ExtractTextPlugin = require('extract-text-webpack-plugin'); -module.exports = { - entry: './example.js', - output: { - path: __dirname + '/dist', - publicPath: '', - filename: 'bundle.js' - }, - module: { - loaders: [ - { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') }, - { test: /\.png$/, loader: 'file-loader' } - ] - }, - plugins: [ - new HtmlWebpackPlugin({ - template: 'template.html' - }), - new ExtractTextPlugin('styles.css') - ] -}; \ No newline at end of file diff --git a/package.json b/package.json index 4d39900..bcce9ec 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,12 @@ { "name": "html-webpack-plugin", - "version": "2.3.0", + "version": "2.4.0", "description": "Simplifies creation of HTML files to serve your webpack bundles", "main": "index.js", "files": [ "index.js", "loader.js", - "default_index.html", - "default_inject_index.html" + "default_index.html" ], "scripts": { "pretest": "jshint *.js spec", @@ -21,7 +20,7 @@ "webpack", "plugin", "html", - "generate" + "html-webpack-plugin" ], "author": "Charles Blaxland (https://github.com/ampedandwired)", "license": "MIT",