diff --git a/.travis.yml b/.travis.yml index 7742397..061af0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,7 @@ node_js: - "0.12" - "0.10" - "4" +script: + - npm test + - npm rm webpack && npm i webpack@beta || true + - npm test diff --git a/appveyor.yml b/appveyor.yml index 5bc2d72..47f137c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,4 +20,4 @@ install: test_script: - node --version - npm --version - - npm test \ No newline at end of file + - npm test diff --git a/examples/appcache/dist/0714810ae3fb211173e2964249507195.png b/examples/appcache/dist/webpack-1/0714810ae3fb211173e2964249507195.png similarity index 100% rename from examples/appcache/dist/0714810ae3fb211173e2964249507195.png rename to examples/appcache/dist/webpack-1/0714810ae3fb211173e2964249507195.png diff --git a/examples/appcache/dist/bundle.js b/examples/appcache/dist/webpack-1/bundle.js similarity index 100% rename from examples/appcache/dist/bundle.js rename to examples/appcache/dist/webpack-1/bundle.js diff --git a/examples/appcache/dist/index.html b/examples/appcache/dist/webpack-1/index.html similarity index 100% rename from examples/appcache/dist/index.html rename to examples/appcache/dist/webpack-1/index.html diff --git a/examples/appcache/dist/manifest.appcache b/examples/appcache/dist/webpack-1/manifest.appcache similarity index 100% rename from examples/appcache/dist/manifest.appcache rename to examples/appcache/dist/webpack-1/manifest.appcache diff --git a/examples/appcache/dist/styles.css b/examples/appcache/dist/webpack-1/styles.css similarity index 100% rename from examples/appcache/dist/styles.css rename to examples/appcache/dist/webpack-1/styles.css diff --git a/examples/custom-template/dist/0714810ae3fb211173e2964249507195.png b/examples/appcache/dist/webpack-2/0714810ae3fb211173e2964249507195.png similarity index 100% rename from examples/custom-template/dist/0714810ae3fb211173e2964249507195.png rename to examples/appcache/dist/webpack-2/0714810ae3fb211173e2964249507195.png diff --git a/examples/appcache/dist/webpack-2/bundle.js b/examples/appcache/dist/webpack-2/bundle.js new file mode 100644 index 0000000..5e10a56 --- /dev/null +++ b/examples/appcache/dist/webpack-2/bundle.js @@ -0,0 +1,60 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].e; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ e: {}, +/******/ i: moduleId, +/******/ l: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.e, module, module.e, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.l = true; + +/******/ // Return the exports of the module +/******/ return module.e; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 1); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports) { + + // removed by extract-text-webpack-plugin + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + __webpack_require__(0); + var h1 = document.createElement('h1'); + h1.innerHTML = 'Hello world!'; + document.body.appendChild(h1); + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/examples/appcache/dist/webpack-2/index.html b/examples/appcache/dist/webpack-2/index.html new file mode 100644 index 0000000..3a2aa9e --- /dev/null +++ b/examples/appcache/dist/webpack-2/index.html @@ -0,0 +1 @@ +Example template \ No newline at end of file diff --git a/examples/appcache/dist/webpack-2/manifest.appcache b/examples/appcache/dist/webpack-2/manifest.appcache new file mode 100644 index 0000000..fa216ec --- /dev/null +++ b/examples/appcache/dist/webpack-2/manifest.appcache @@ -0,0 +1,9 @@ +CACHE MANIFEST +# 4dd687f1b70b04b5bb2e + +0714810ae3fb211173e2964249507195.png +bundle.js +styles.css + +NETWORK: +* diff --git a/examples/custom-template/dist/styles.css b/examples/appcache/dist/webpack-2/styles.css similarity index 100% rename from examples/custom-template/dist/styles.css rename to examples/appcache/dist/webpack-2/styles.css diff --git a/examples/appcache/webpack.config.js b/examples/appcache/webpack.config.js index 503cc88..2d12791 100755 --- a/examples/appcache/webpack.config.js +++ b/examples/appcache/webpack.config.js @@ -1,10 +1,12 @@ var AppCachePlugin = require('appcache-webpack-plugin'); var HtmlWebpackPlugin = require('../..'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); +var webpackMajorVersion = require('webpack/package.json').version.split('.')[0]; + module.exports = { entry: './example.js', output: { - path: __dirname + '/dist', + path: __dirname + '/dist/webpack-' + webpackMajorVersion, publicPath: '', filename: 'bundle.js' }, @@ -28,4 +30,3 @@ module.exports = { new ExtractTextPlugin('styles.css') ] }; - diff --git a/examples/build-examples.js b/examples/build-examples.js new file mode 100644 index 0000000..563224c --- /dev/null +++ b/examples/build-examples.js @@ -0,0 +1,24 @@ +/** + * This file is just a helper to compile all examples. + * + * You could do the same by going into each example and execute + * `webpack` + */ +var webpackMajorVersion = require('webpack/package.json').version.split('.')[0]; + +var fs = require('fs'); +var path = require('path'); +var execSync = require('child_process').execSync; +var rm_rf = require('rimraf'); +var webpackBin = path.resolve(__dirname, '..', 'node_modules', '.bin', 'webpack'); + +var examples = fs.readdirSync(__dirname).filter(function (file) { + return fs.statSync(path.join(__dirname, file)).isDirectory(); +}); + +examples.forEach(function (exampleName) { + var examplePath = path.join(__dirname, exampleName); + var configFile = path.join(examplePath, 'webpack.config.js'); + rm_rf.sync(path.join(examplePath, 'dist', 'webpack-' + webpackMajorVersion)); + execSync(webpackBin + ' --context "' + examplePath + '" --config "' + configFile + '"'); +}); diff --git a/examples/html-loader/dist/0714810ae3fb211173e2964249507195.png b/examples/custom-template/dist/webpack-1/0714810ae3fb211173e2964249507195.png similarity index 100% rename from examples/html-loader/dist/0714810ae3fb211173e2964249507195.png rename to examples/custom-template/dist/webpack-1/0714810ae3fb211173e2964249507195.png diff --git a/examples/custom-template/dist/bundle.js b/examples/custom-template/dist/webpack-1/bundle.js similarity index 100% rename from examples/custom-template/dist/bundle.js rename to examples/custom-template/dist/webpack-1/bundle.js diff --git a/examples/custom-template/dist/index.html b/examples/custom-template/dist/webpack-1/index.html similarity index 100% rename from examples/custom-template/dist/index.html rename to examples/custom-template/dist/webpack-1/index.html diff --git a/examples/favicon/dist/styles.css b/examples/custom-template/dist/webpack-1/styles.css similarity index 100% rename from examples/favicon/dist/styles.css rename to examples/custom-template/dist/webpack-1/styles.css diff --git a/examples/jade-loader/dist/0714810ae3fb211173e2964249507195.png b/examples/custom-template/dist/webpack-2/0714810ae3fb211173e2964249507195.png similarity index 100% rename from examples/jade-loader/dist/0714810ae3fb211173e2964249507195.png rename to examples/custom-template/dist/webpack-2/0714810ae3fb211173e2964249507195.png diff --git a/examples/custom-template/dist/webpack-2/bundle.js b/examples/custom-template/dist/webpack-2/bundle.js new file mode 100644 index 0000000..5e10a56 --- /dev/null +++ b/examples/custom-template/dist/webpack-2/bundle.js @@ -0,0 +1,60 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].e; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ e: {}, +/******/ i: moduleId, +/******/ l: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.e, module, module.e, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.l = true; + +/******/ // Return the exports of the module +/******/ return module.e; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 1); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports) { + + // removed by extract-text-webpack-plugin + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + __webpack_require__(0); + var h1 = document.createElement('h1'); + h1.innerHTML = 'Hello world!'; + document.body.appendChild(h1); + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/examples/custom-template/dist/webpack-2/index.html b/examples/custom-template/dist/webpack-2/index.html new file mode 100644 index 0000000..a9d8bf4 --- /dev/null +++ b/examples/custom-template/dist/webpack-2/index.html @@ -0,0 +1,12 @@ + + + + + Webpack App + + + +

Partial

+ + + \ No newline at end of file diff --git a/examples/html-loader/dist/styles.css b/examples/custom-template/dist/webpack-2/styles.css similarity index 100% rename from examples/html-loader/dist/styles.css rename to examples/custom-template/dist/webpack-2/styles.css diff --git a/examples/custom-template/webpack.config.js b/examples/custom-template/webpack.config.js index 967ddb2..d512d4a 100755 --- a/examples/custom-template/webpack.config.js +++ b/examples/custom-template/webpack.config.js @@ -1,9 +1,11 @@ var HtmlWebpackPlugin = require('../..'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); +var webpackMajorVersion = require('webpack/package.json').version.split('.')[0]; + module.exports = { entry: './example.js', output: { - path: __dirname + '/dist', + path: __dirname + '/dist/webpack-' + webpackMajorVersion, publicPath: '', filename: 'bundle.js' }, diff --git a/examples/default/dist/bundle.js b/examples/default/dist/webpack-1/bundle.js similarity index 100% rename from examples/default/dist/bundle.js rename to examples/default/dist/webpack-1/bundle.js diff --git a/examples/default/dist/index.html b/examples/default/dist/webpack-1/index.html similarity index 100% rename from examples/default/dist/index.html rename to examples/default/dist/webpack-1/index.html diff --git a/examples/default/dist/webpack-2/bundle.js b/examples/default/dist/webpack-2/bundle.js new file mode 100644 index 0000000..df25951 --- /dev/null +++ b/examples/default/dist/webpack-2/bundle.js @@ -0,0 +1,404 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].e; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ e: {}, +/******/ i: moduleId, +/******/ l: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.e, module, module.e, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.l = true; + +/******/ // Return the exports of the module +/******/ return module.e; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 1); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + // style-loader: Adds some css to the DOM by adding a \ No newline at end of file diff --git a/examples/inline/dist/webpack-2/styles.css b/examples/inline/dist/webpack-2/styles.css new file mode 100644 index 0000000..232a2cd --- /dev/null +++ b/examples/inline/dist/webpack-2/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/inline/webpack.config.js b/examples/inline/webpack.config.js index 581a2ad..f46ca6a 100755 --- a/examples/inline/webpack.config.js +++ b/examples/inline/webpack.config.js @@ -1,9 +1,11 @@ var HtmlWebpackPlugin = require('../..'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); +var webpackMajorVersion = require('webpack/package.json').version.split('.')[0]; + module.exports = { entry: './example.js', output: { - path: __dirname + '/dist', + path: __dirname + '/dist/webpack-' + webpackMajorVersion, publicPath: '', filename: 'bundle.js' }, diff --git a/examples/jade-loader/dist/webpack-1/0714810ae3fb211173e2964249507195.png b/examples/jade-loader/dist/webpack-1/0714810ae3fb211173e2964249507195.png new file mode 100644 index 0000000..d71b3d7 Binary files /dev/null and b/examples/jade-loader/dist/webpack-1/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/jade-loader/dist/bundle.js b/examples/jade-loader/dist/webpack-1/bundle.js similarity index 100% rename from examples/jade-loader/dist/bundle.js rename to examples/jade-loader/dist/webpack-1/bundle.js diff --git a/examples/jade-loader/dist/webpack-1/favicon.ico b/examples/jade-loader/dist/webpack-1/favicon.ico new file mode 100644 index 0000000..be74abd Binary files /dev/null and b/examples/jade-loader/dist/webpack-1/favicon.ico differ diff --git a/examples/jade-loader/dist/index.html b/examples/jade-loader/dist/webpack-1/index.html similarity index 100% rename from examples/jade-loader/dist/index.html rename to examples/jade-loader/dist/webpack-1/index.html diff --git a/examples/jade-loader/dist/webpack-1/styles.css b/examples/jade-loader/dist/webpack-1/styles.css new file mode 100644 index 0000000..232a2cd --- /dev/null +++ b/examples/jade-loader/dist/webpack-1/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/jade-loader/dist/webpack-2/0714810ae3fb211173e2964249507195.png b/examples/jade-loader/dist/webpack-2/0714810ae3fb211173e2964249507195.png new file mode 100644 index 0000000..d71b3d7 Binary files /dev/null and b/examples/jade-loader/dist/webpack-2/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/jade-loader/dist/webpack-2/bundle.js b/examples/jade-loader/dist/webpack-2/bundle.js new file mode 100644 index 0000000..dadd3df --- /dev/null +++ b/examples/jade-loader/dist/webpack-2/bundle.js @@ -0,0 +1,344 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].e; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ e: {}, +/******/ i: moduleId, +/******/ l: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.e, module, module.e, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.l = true; + +/******/ // Return the exports of the module +/******/ return module.e; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 2); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports) { + + // removed by extract-text-webpack-plugin + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + var jade = __webpack_require__(4); + + module.e = function template(locals) { + var buf = []; + var jade_mixins = {}; + var jade_interp; + ;var locals_for_with = (locals || {});(function (time) { + buf.push("
Current time

" + (jade.escape((jade_interp = time.toISOString()) == null ? '' : jade_interp)) + "

");}.call(this,"time" in locals_for_with?locals_for_with.time:typeof time!=="undefined"?time:undefined));;return buf.join(""); + } + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + __webpack_require__(0); + // Use the same template for the frontend code + var template = __webpack_require__(1); + + setInterval(function () { + var div = document.getElementById('main'); + div.innerHTML = template({ time: new Date() }); + div.style.color = 'navy'; + }, 1000); + + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + + module.e = __webpack_require__.p + "0714810ae3fb211173e2964249507195.png"; + +/***/ }, +/* 4 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + /** + * Merge two attribute objects giving precedence + * to values in object `b`. Classes are special-cased + * allowing for arrays and merging/joining appropriately + * resulting in a string. + * + * @param {Object} a + * @param {Object} b + * @return {Object} a + * @api private + */ + + exports.merge = function merge(a, b) { + if (arguments.length === 1) { + var attrs = a[0]; + for (var i = 1; i < a.length; i++) { + attrs = merge(attrs, a[i]); + } + return attrs; + } + var ac = a['class']; + var bc = b['class']; + + if (ac || bc) { + ac = ac || []; + bc = bc || []; + if (!Array.isArray(ac)) ac = [ac]; + if (!Array.isArray(bc)) bc = [bc]; + a['class'] = ac.concat(bc).filter(nulls); + } + + for (var key in b) { + if (key != 'class') { + a[key] = b[key]; + } + } + + return a; + }; + + /** + * Filter null `val`s. + * + * @param {*} val + * @return {Boolean} + * @api private + */ + + function nulls(val) { + return val != null && val !== ''; + } + + /** + * join array as classes. + * + * @param {*} val + * @return {String} + */ + exports.joinClasses = joinClasses; + function joinClasses(val) { + return (Array.isArray(val) ? val.map(joinClasses) : + (val && typeof val === 'object') ? Object.keys(val).filter(function (key) { return val[key]; }) : + [val]).filter(nulls).join(' '); + } + + /** + * Render the given classes. + * + * @param {Array} classes + * @param {Array.} escaped + * @return {String} + */ + exports.cls = function cls(classes, escaped) { + var buf = []; + for (var i = 0; i < classes.length; i++) { + if (escaped && escaped[i]) { + buf.push(exports.escape(joinClasses([classes[i]]))); + } else { + buf.push(joinClasses(classes[i])); + } + } + var text = joinClasses(buf); + if (text.length) { + return ' class="' + text + '"'; + } else { + return ''; + } + }; + + + exports.style = function (val) { + if (val && typeof val === 'object') { + return Object.keys(val).map(function (style) { + return style + ':' + val[style]; + }).join(';'); + } else { + return val; + } + }; + /** + * Render the given attribute. + * + * @param {String} key + * @param {String} val + * @param {Boolean} escaped + * @param {Boolean} terse + * @return {String} + */ + exports.attr = function attr(key, val, escaped, terse) { + if (key === 'style') { + val = exports.style(val); + } + if ('boolean' == typeof val || null == val) { + if (val) { + return ' ' + (terse ? key : key + '="' + key + '"'); + } else { + return ''; + } + } else if (0 == key.indexOf('data') && 'string' != typeof val) { + if (JSON.stringify(val).indexOf('&') !== -1) { + console.warn('Since Jade 2.0.0, ampersands (`&`) in data attributes ' + + 'will be escaped to `&`'); + }; + if (val && typeof val.toISOString === 'function') { + console.warn('Jade will eliminate the double quotes around dates in ' + + 'ISO form after 2.0.0'); + } + return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, ''') + "'"; + } else if (escaped) { + if (val && typeof val.toISOString === 'function') { + console.warn('Jade will stringify dates in ISO form after 2.0.0'); + } + return ' ' + key + '="' + exports.escape(val) + '"'; + } else { + if (val && typeof val.toISOString === 'function') { + console.warn('Jade will stringify dates in ISO form after 2.0.0'); + } + return ' ' + key + '="' + val + '"'; + } + }; + + /** + * Render the given attributes object. + * + * @param {Object} obj + * @param {Object} escaped + * @return {String} + */ + exports.attrs = function attrs(obj, terse){ + var buf = []; + + var keys = Object.keys(obj); + + if (keys.length) { + for (var i = 0; i < keys.length; ++i) { + var key = keys[i] + , val = obj[key]; + + if ('class' == key) { + if (val = joinClasses(val)) { + buf.push(' ' + key + '="' + val + '"'); + } + } else { + buf.push(exports.attr(key, val, false, terse)); + } + } + } + + return buf.join(''); + }; + + /** + * Escape the given string of `html`. + * + * @param {String} html + * @return {String} + * @api private + */ + + var jade_encode_html_rules = { + '&': '&', + '<': '<', + '>': '>', + '"': '"' + }; + var jade_match_html = /[&<>"]/g; + + function jade_encode_char(c) { + return jade_encode_html_rules[c] || c; + } + + exports.escape = jade_escape; + function jade_escape(html){ + var result = String(html).replace(jade_match_html, jade_encode_char); + if (result === '' + html) return html; + else return result; + }; + + /** + * Re-throw the given `err` in context to the + * the jade in `filename` at the given `lineno`. + * + * @param {Error} err + * @param {String} filename + * @param {String} lineno + * @api private + */ + + exports.rethrow = function rethrow(err, filename, lineno, str){ + if (!(err instanceof Error)) throw err; + if ((typeof window != 'undefined' || !filename) && !str) { + err.message += ' on line ' + lineno; + throw err; + } + try { + str = str || __webpack_require__(5).readFileSync(filename, 'utf8') + } catch (ex) { + rethrow(err, null, lineno) + } + var context = 3 + , lines = str.split('\n') + , start = Math.max(lineno - context, 0) + , end = Math.min(lines.length, lineno + context); + + // Error context + var context = lines.slice(start, end).map(function(line, i){ + var curr = i + start + 1; + return (curr == lineno ? ' > ' : ' ') + + curr + + '| ' + + line; + }).join('\n'); + + // Alter exception message + err.path = filename; + err.message = (filename || 'Jade') + ':' + lineno + + '\n' + context + '\n\n' + err.message; + throw err; + }; + + exports.DebugItem = function DebugItem(lineno, filename) { + this.lineno = lineno; + this.filename = filename; + } + + +/***/ }, +/* 5 */ +/***/ function(module, exports) { + + /* (ignored) */ + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/examples/jade-loader/dist/webpack-2/favicon.ico b/examples/jade-loader/dist/webpack-2/favicon.ico new file mode 100644 index 0000000..be74abd Binary files /dev/null and b/examples/jade-loader/dist/webpack-2/favicon.ico differ diff --git a/examples/jade-loader/dist/webpack-2/index.html b/examples/jade-loader/dist/webpack-2/index.html new file mode 100644 index 0000000..e720b25 --- /dev/null +++ b/examples/jade-loader/dist/webpack-2/index.html @@ -0,0 +1 @@ +Jade demo
Current time

1998-12-31T23:00:00.000Z

\ No newline at end of file diff --git a/examples/jade-loader/dist/webpack-2/styles.css b/examples/jade-loader/dist/webpack-2/styles.css new file mode 100644 index 0000000..232a2cd --- /dev/null +++ b/examples/jade-loader/dist/webpack-2/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/jade-loader/webpack.config.js b/examples/jade-loader/webpack.config.js index 3d27453..ed3d56f 100755 --- a/examples/jade-loader/webpack.config.js +++ b/examples/jade-loader/webpack.config.js @@ -1,9 +1,10 @@ var HtmlWebpackPlugin = require('../..'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); +var webpackMajorVersion = require('webpack/package.json').version.split('.')[0]; module.exports = { entry: './example.js', output: { - path: __dirname + '/dist', + path: __dirname + '/dist/webpack-' + webpackMajorVersion, publicPath: '', filename: 'bundle.js' }, diff --git a/examples/javascript-advanced/dist/webpack-1/0714810ae3fb211173e2964249507195.png b/examples/javascript-advanced/dist/webpack-1/0714810ae3fb211173e2964249507195.png new file mode 100644 index 0000000..d71b3d7 Binary files /dev/null and b/examples/javascript-advanced/dist/webpack-1/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/javascript-advanced/dist/bundle.js b/examples/javascript-advanced/dist/webpack-1/bundle.js similarity index 100% rename from examples/javascript-advanced/dist/bundle.js rename to examples/javascript-advanced/dist/webpack-1/bundle.js diff --git a/examples/javascript-advanced/dist/index.html b/examples/javascript-advanced/dist/webpack-1/index.html similarity index 100% rename from examples/javascript-advanced/dist/index.html rename to examples/javascript-advanced/dist/webpack-1/index.html diff --git a/examples/javascript-advanced/dist/webpack-1/styles.css b/examples/javascript-advanced/dist/webpack-1/styles.css new file mode 100644 index 0000000..232a2cd --- /dev/null +++ b/examples/javascript-advanced/dist/webpack-1/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/javascript-advanced/dist/webpack-2/0714810ae3fb211173e2964249507195.png b/examples/javascript-advanced/dist/webpack-2/0714810ae3fb211173e2964249507195.png new file mode 100644 index 0000000..d71b3d7 Binary files /dev/null and b/examples/javascript-advanced/dist/webpack-2/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/javascript-advanced/dist/webpack-2/bundle.js b/examples/javascript-advanced/dist/webpack-2/bundle.js new file mode 100644 index 0000000..c990b80 --- /dev/null +++ b/examples/javascript-advanced/dist/webpack-2/bundle.js @@ -0,0 +1,62 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].e; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ e: {}, +/******/ i: moduleId, +/******/ l: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.e, module, module.e, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.l = true; + +/******/ // Return the exports of the module +/******/ return module.e; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 2); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + eval("// This file is used for frontend and backend\n'use strict';\n\n// If compiled by the html-webpack-plugin\n// HTML_WEBPACK_PLUGIN is set to true:\nvar backend = typeof HTML_WEBPACK_PLUGIN !== 'undefined';\n\nmodule.e = function () {\n return 'Hello World from ' + (backend ? 'backend' : 'frontend');\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./universial.js\n ** module id = 0\n ** module chunks = 0\n **/\n\n//# sourceURL=webpack:///./universial.js?"); + +/***/ }, +/* 1 */ +/***/ function(module, exports) { + + eval("// removed by extract-text-webpack-plugin\n\n/*****************\n ** WEBPACK FOOTER\n ** ./main.css\n ** module id = 1\n ** module chunks = 0\n **/\n\n//# sourceURL=webpack:///./main.css?"); + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + eval("__webpack_require__(1);\n\nvar universal = __webpack_require__(0);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./example.js\n ** module id = 2\n ** module chunks = 0\n **/\n\n//# sourceURL=webpack:///./example.js?"); + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/examples/javascript-advanced/dist/webpack-2/index.html b/examples/javascript-advanced/dist/webpack-2/index.html new file mode 100644 index 0000000..194f6fb --- /dev/null +++ b/examples/javascript-advanced/dist/webpack-2/index.html @@ -0,0 +1,2 @@ +Webpack AppHello World from backend -

Partial

+ \ No newline at end of file diff --git a/examples/javascript-advanced/dist/webpack-2/styles.css b/examples/javascript-advanced/dist/webpack-2/styles.css new file mode 100644 index 0000000..232a2cd --- /dev/null +++ b/examples/javascript-advanced/dist/webpack-2/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/javascript-advanced/webpack.config.js b/examples/javascript-advanced/webpack.config.js index e0d314e..a964787 100644 --- a/examples/javascript-advanced/webpack.config.js +++ b/examples/javascript-advanced/webpack.config.js @@ -1,9 +1,10 @@ var HtmlWebpackPlugin = require('../..'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); +var webpackMajorVersion = require('webpack/package.json').version.split('.')[0]; module.exports = { entry: './example.js', output: { - path: __dirname + '/dist', + path: __dirname + '/dist/webpack-' + webpackMajorVersion, publicPath: '', filename: 'bundle.js' }, diff --git a/examples/javascript/dist/webpack-1/0714810ae3fb211173e2964249507195.png b/examples/javascript/dist/webpack-1/0714810ae3fb211173e2964249507195.png new file mode 100644 index 0000000..d71b3d7 Binary files /dev/null and b/examples/javascript/dist/webpack-1/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/javascript/dist/bundle.js b/examples/javascript/dist/webpack-1/bundle.js similarity index 100% rename from examples/javascript/dist/bundle.js rename to examples/javascript/dist/webpack-1/bundle.js diff --git a/examples/javascript/dist/index.html b/examples/javascript/dist/webpack-1/index.html similarity index 64% rename from examples/javascript/dist/index.html rename to examples/javascript/dist/webpack-1/index.html index d1d7cd9..f4f3e23 100644 --- a/examples/javascript/dist/index.html +++ b/examples/javascript/dist/webpack-1/index.html @@ -1,2 +1,2 @@ -Hello World from backend2016-01-20T15:46:57.631Z

Partial

+Hello World from backend2016-03-21T08:52:41.516Z

Partial

\ No newline at end of file diff --git a/examples/javascript/dist/webpack-1/styles.css b/examples/javascript/dist/webpack-1/styles.css new file mode 100644 index 0000000..232a2cd --- /dev/null +++ b/examples/javascript/dist/webpack-1/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/javascript/dist/webpack-2/0714810ae3fb211173e2964249507195.png b/examples/javascript/dist/webpack-2/0714810ae3fb211173e2964249507195.png new file mode 100644 index 0000000..d71b3d7 Binary files /dev/null and b/examples/javascript/dist/webpack-2/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/javascript/dist/webpack-2/bundle.js b/examples/javascript/dist/webpack-2/bundle.js new file mode 100644 index 0000000..c990b80 --- /dev/null +++ b/examples/javascript/dist/webpack-2/bundle.js @@ -0,0 +1,62 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].e; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ e: {}, +/******/ i: moduleId, +/******/ l: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.e, module, module.e, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.l = true; + +/******/ // Return the exports of the module +/******/ return module.e; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 2); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + eval("// This file is used for frontend and backend\n'use strict';\n\n// If compiled by the html-webpack-plugin\n// HTML_WEBPACK_PLUGIN is set to true:\nvar backend = typeof HTML_WEBPACK_PLUGIN !== 'undefined';\n\nmodule.e = function () {\n return 'Hello World from ' + (backend ? 'backend' : 'frontend');\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./universial.js\n ** module id = 0\n ** module chunks = 0\n **/\n\n//# sourceURL=webpack:///./universial.js?"); + +/***/ }, +/* 1 */ +/***/ function(module, exports) { + + eval("// removed by extract-text-webpack-plugin\n\n/*****************\n ** WEBPACK FOOTER\n ** ./main.css\n ** module id = 1\n ** module chunks = 0\n **/\n\n//# sourceURL=webpack:///./main.css?"); + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + eval("__webpack_require__(1);\n\nvar universal = __webpack_require__(0);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./example.js\n ** module id = 2\n ** module chunks = 0\n **/\n\n//# sourceURL=webpack:///./example.js?"); + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/examples/javascript/dist/webpack-2/index.html b/examples/javascript/dist/webpack-2/index.html new file mode 100644 index 0000000..67c494f --- /dev/null +++ b/examples/javascript/dist/webpack-2/index.html @@ -0,0 +1,2 @@ +Hello World from backend2016-03-22T18:35:15.191Z

Partial

+ \ No newline at end of file diff --git a/examples/javascript/dist/webpack-2/styles.css b/examples/javascript/dist/webpack-2/styles.css new file mode 100644 index 0000000..232a2cd --- /dev/null +++ b/examples/javascript/dist/webpack-2/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/javascript/webpack.config.js b/examples/javascript/webpack.config.js index e0d314e..a964787 100644 --- a/examples/javascript/webpack.config.js +++ b/examples/javascript/webpack.config.js @@ -1,9 +1,10 @@ var HtmlWebpackPlugin = require('../..'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); +var webpackMajorVersion = require('webpack/package.json').version.split('.')[0]; module.exports = { entry: './example.js', output: { - path: __dirname + '/dist', + path: __dirname + '/dist/webpack-' + webpackMajorVersion, publicPath: '', filename: 'bundle.js' }, diff --git a/lib/chunksorter.js b/lib/chunksorter.js index ca8753e..fc41ae5 100644 --- a/lib/chunksorter.js +++ b/lib/chunksorter.js @@ -81,3 +81,10 @@ module.exports.none = function (chunks) { * Defines the default sorter. */ module.exports.auto = module.exports.id; + +// In webpack 2 the ids have been flipped. +// Therefore the id sort doesn't work the same way as it did for webpack 1 +// Luckily the dependency sort is working as expected +if (require('webpack/package.json').version.split('.')[0] === '2') { + module.exports.auto = module.exports.dependency; +} diff --git a/package.json b/package.json index 856507d..0b69db3 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "prepublish": "npm run test", "pretest": "semistandard", - "recompile": "node examples/rebuild.js", + "build-examples": "node examples/build-examples.js", "test": "jasmine" }, "repository": { diff --git a/spec/BasicSpec.js b/spec/BasicSpec.js index a653f33..fc70fd0 100644 --- a/spec/BasicSpec.js +++ b/spec/BasicSpec.js @@ -20,6 +20,8 @@ var HtmlWebpackPlugin = require('../index.js'); var OUTPUT_DIR = path.join(__dirname, '../dist'); +jasmine.getEnv().defaultTimeoutInterval = 5000; + function testHtmlPlugin (webpackConfig, expectedResults, outputFile, done, expectErrors, expectWarnings) { outputFile = outputFile || 'index.html'; webpack(webpackConfig, function (err, stats) { @@ -106,7 +108,7 @@ describe('HtmlWebpackPlugin', function () { }, [' - <% } %> - - - diff --git a/spec/fixtures/template.jade b/spec/fixtures/template.jade new file mode 100644 index 0000000..5f56e94 --- /dev/null +++ b/spec/fixtures/template.jade @@ -0,0 +1,9 @@ +doctype html +html + head + meta(http-equiv="Content-type" content="text/html; charset=utf-8") + title Demo + body + p Some unique text + each jsFile in htmlWebpackPlugin.files.js + script(src!=jsFile)