diff --git a/README.md b/README.md index 81913ad..f31a7e0 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ Allowed values are as follows: - `cache`: `true | false` if `true` (default) try to emit the file only if it was changed. - `showErrors`: `true | false` if `true` (default) errors details will be written into the HTML page. - `chunks`: Allows you to add only some chunks (e.g. only the unit-test chunk) -- `chunksSortMode`: Allows to control how chunks should be sorted before they are included to the html. Allowed values: 'none' | 'auto' | 'dependency' | {function} - default: 'auto' +- `chunksSortMode`: Allows to control how chunks should be sorted before they are included to the html. Allowed values: 'none' | 'auto' | 'dependency' |'manual' | {function} - default: 'auto' - `excludeChunks`: Allows you to skip some chunks (e.g. don't add the unit-test chunk) - `xhtml`: `true | false` If `true` render the `link` tags as self-closing, XHTML compliant. Default is `false` diff --git a/examples/sort-manually/a.js b/examples/sort-manually/a.js new file mode 100644 index 0000000..5175209 --- /dev/null +++ b/examples/sort-manually/a.js @@ -0,0 +1,4 @@ +require('./main.css'); +var h1 = document.createElement('h1'); +h1.innerHTML = 'a!'; +document.body.appendChild(h1); diff --git a/examples/sort-manually/b.js b/examples/sort-manually/b.js new file mode 100644 index 0000000..2744f27 --- /dev/null +++ b/examples/sort-manually/b.js @@ -0,0 +1,3 @@ +var h1 = document.createElement('h1'); +h1.innerHTML = 'b!'; +document.body.appendChild(h1); diff --git a/examples/sort-manually/c.js b/examples/sort-manually/c.js new file mode 100644 index 0000000..9d70cf5 --- /dev/null +++ b/examples/sort-manually/c.js @@ -0,0 +1,3 @@ +var h1 = document.createElement('h1'); +h1.innerHTML = 'c!'; +document.body.appendChild(h1); diff --git a/examples/sort-manually/d.js b/examples/sort-manually/d.js new file mode 100644 index 0000000..bd4f3ef --- /dev/null +++ b/examples/sort-manually/d.js @@ -0,0 +1,3 @@ +var h1 = document.createElement('h1'); +h1.innerHTML = 'd!'; +document.body.appendChild(h1); diff --git a/examples/sort-manually/dist/webpack-1/0714810ae3fb211173e2964249507195.png b/examples/sort-manually/dist/webpack-1/0714810ae3fb211173e2964249507195.png new file mode 100644 index 0000000..d71b3d7 Binary files /dev/null and b/examples/sort-manually/dist/webpack-1/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/sort-manually/dist/webpack-1/a.js b/examples/sort-manually/dist/webpack-1/a.js new file mode 100644 index 0000000..7878b97 --- /dev/null +++ b/examples/sort-manually/dist/webpack-1/a.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].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // 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__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(1); + var h1 = document.createElement('h1'); + h1.innerHTML = 'a!'; + document.body.appendChild(h1); + + +/***/ }), +/* 1 */ +/***/ (function(module, exports) { + + // removed by extract-text-webpack-plugin + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-1/b.js b/examples/sort-manually/dist/webpack-1/b.js new file mode 100644 index 0000000..1c65900 --- /dev/null +++ b/examples/sort-manually/dist/webpack-1/b.js @@ -0,0 +1,53 @@ +/******/ (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].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // 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__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + + var h1 = document.createElement('h1'); + h1.innerHTML = 'b!'; + document.body.appendChild(h1); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-1/c.js b/examples/sort-manually/dist/webpack-1/c.js new file mode 100644 index 0000000..4b82961 --- /dev/null +++ b/examples/sort-manually/dist/webpack-1/c.js @@ -0,0 +1,53 @@ +/******/ (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].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // 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__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + + var h1 = document.createElement('h1'); + h1.innerHTML = 'c!'; + document.body.appendChild(h1); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-1/d.js b/examples/sort-manually/dist/webpack-1/d.js new file mode 100644 index 0000000..8bfebf2 --- /dev/null +++ b/examples/sort-manually/dist/webpack-1/d.js @@ -0,0 +1,53 @@ +/******/ (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].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // 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__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + + var h1 = document.createElement('h1'); + h1.innerHTML = 'd!'; + document.body.appendChild(h1); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-1/e.js b/examples/sort-manually/dist/webpack-1/e.js new file mode 100644 index 0000000..5acab06 --- /dev/null +++ b/examples/sort-manually/dist/webpack-1/e.js @@ -0,0 +1,53 @@ +/******/ (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].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // 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__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + + var h1 = document.createElement('h1'); + h1.innerHTML = 'e!'; + document.body.appendChild(h1); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-1/first-file.html b/examples/sort-manually/dist/webpack-1/first-file.html new file mode 100644 index 0000000..afacda4 --- /dev/null +++ b/examples/sort-manually/dist/webpack-1/first-file.html @@ -0,0 +1,11 @@ + + + + + Example template + + + + + + \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-1/second-file.html b/examples/sort-manually/dist/webpack-1/second-file.html new file mode 100644 index 0000000..d6d80d3 --- /dev/null +++ b/examples/sort-manually/dist/webpack-1/second-file.html @@ -0,0 +1,11 @@ + + + + + Example template + + + + + + \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-1/styles.css b/examples/sort-manually/dist/webpack-1/styles.css new file mode 100644 index 0000000..232a2cd --- /dev/null +++ b/examples/sort-manually/dist/webpack-1/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-2/0714810ae3fb211173e2964249507195.png b/examples/sort-manually/dist/webpack-2/0714810ae3fb211173e2964249507195.png new file mode 100644 index 0000000..d71b3d7 Binary files /dev/null and b/examples/sort-manually/dist/webpack-2/0714810ae3fb211173e2964249507195.png differ diff --git a/examples/sort-manually/dist/webpack-2/a.js b/examples/sort-manually/dist/webpack-2/a.js new file mode 100644 index 0000000..2251fb1 --- /dev/null +++ b/examples/sort-manually/dist/webpack-2/a.js @@ -0,0 +1,86 @@ +/******/ (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].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __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 = 'a!'; +document.body.appendChild(h1); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-2/b.js b/examples/sort-manually/dist/webpack-2/b.js new file mode 100644 index 0000000..e4a6181 --- /dev/null +++ b/examples/sort-manually/dist/webpack-2/b.js @@ -0,0 +1,81 @@ +/******/ (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].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 2); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ 2: +/***/ (function(module, exports) { + +var h1 = document.createElement('h1'); +h1.innerHTML = 'b!'; +document.body.appendChild(h1); + + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-2/c.js b/examples/sort-manually/dist/webpack-2/c.js new file mode 100644 index 0000000..d52f794 --- /dev/null +++ b/examples/sort-manually/dist/webpack-2/c.js @@ -0,0 +1,81 @@ +/******/ (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].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 3); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ 3: +/***/ (function(module, exports) { + +var h1 = document.createElement('h1'); +h1.innerHTML = 'c!'; +document.body.appendChild(h1); + + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-2/d.js b/examples/sort-manually/dist/webpack-2/d.js new file mode 100644 index 0000000..6377a79 --- /dev/null +++ b/examples/sort-manually/dist/webpack-2/d.js @@ -0,0 +1,81 @@ +/******/ (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].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 4); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ 4: +/***/ (function(module, exports) { + +var h1 = document.createElement('h1'); +h1.innerHTML = 'd!'; +document.body.appendChild(h1); + + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-2/e.js b/examples/sort-manually/dist/webpack-2/e.js new file mode 100644 index 0000000..e7ebc09 --- /dev/null +++ b/examples/sort-manually/dist/webpack-2/e.js @@ -0,0 +1,81 @@ +/******/ (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].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 5); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ 5: +/***/ (function(module, exports) { + +var h1 = document.createElement('h1'); +h1.innerHTML = 'e!'; +document.body.appendChild(h1); + + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-2/first-file.html b/examples/sort-manually/dist/webpack-2/first-file.html new file mode 100644 index 0000000..afacda4 --- /dev/null +++ b/examples/sort-manually/dist/webpack-2/first-file.html @@ -0,0 +1,11 @@ + + + + + Example template + + + + + + \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-2/second-file.html b/examples/sort-manually/dist/webpack-2/second-file.html new file mode 100644 index 0000000..d6d80d3 --- /dev/null +++ b/examples/sort-manually/dist/webpack-2/second-file.html @@ -0,0 +1,11 @@ + + + + + Example template + + + + + + \ No newline at end of file diff --git a/examples/sort-manually/dist/webpack-2/styles.css b/examples/sort-manually/dist/webpack-2/styles.css new file mode 100644 index 0000000..232a2cd --- /dev/null +++ b/examples/sort-manually/dist/webpack-2/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/sort-manually/e.js b/examples/sort-manually/e.js new file mode 100644 index 0000000..6083d99 --- /dev/null +++ b/examples/sort-manually/e.js @@ -0,0 +1,3 @@ +var h1 = document.createElement('h1'); +h1.innerHTML = 'e!'; +document.body.appendChild(h1); diff --git a/examples/sort-manually/logo.png b/examples/sort-manually/logo.png new file mode 100644 index 0000000..d71b3d7 Binary files /dev/null and b/examples/sort-manually/logo.png differ diff --git a/examples/sort-manually/main.css b/examples/sort-manually/main.css new file mode 100644 index 0000000..232a2cd --- /dev/null +++ b/examples/sort-manually/main.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/sort-manually/template.html b/examples/sort-manually/template.html new file mode 100644 index 0000000..b7b4f97 --- /dev/null +++ b/examples/sort-manually/template.html @@ -0,0 +1,11 @@ + + + + + Example template + + + + + + \ No newline at end of file diff --git a/examples/sort-manually/webpack.config.js b/examples/sort-manually/webpack.config.js new file mode 100644 index 0000000..98b0b18 --- /dev/null +++ b/examples/sort-manually/webpack.config.js @@ -0,0 +1,43 @@ +var path = require('path'); +var HtmlWebpackPlugin = require('../..'); +var ExtractTextPlugin = require('extract-text-webpack-plugin'); +var webpackMajorVersion = require('webpack/package.json').version.split('.')[0]; +module.exports = { + context: __dirname, + entry: { + b: './b.js', + d: './d.js', + a: './a.js', + c: './c.js', + e: './e.js' + }, + output: { + path: path.join(__dirname, 'dist/webpack-' + webpackMajorVersion), + publicPath: '', + filename: '[name].js' + }, + module: { + loaders: [ + { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') }, + { test: /\.png$/, loader: 'file-loader' }, + { test: /\.html$/, loader: 'html-loader' } + ] + }, + plugins: [ + new HtmlWebpackPlugin({ + inject: true, + filename: 'first-file.html', + template: 'template.html', + chunksSortMode: 'manual', + chunks: ['a', 'b', 'c'] + }), + new HtmlWebpackPlugin({ + inject: true, + filename: 'second-file.html', + template: 'template.html', + chunksSortMode: 'manual', + chunks: ['a', 'b', 'd'] + }), + new ExtractTextPlugin('styles.css') + ] +}; diff --git a/index.js b/index.js index 4e0bfe8..b6f9578 100644 --- a/index.js +++ b/index.js @@ -344,7 +344,7 @@ HtmlWebpackPlugin.prototype.sortChunks = function (chunks, sortMode) { } // Check if the given sort mode is a valid chunkSorter sort mode if (typeof chunkSorter[sortMode] !== 'undefined') { - return chunkSorter[sortMode](chunks); + return chunkSorter[sortMode](chunks, this.options.chunks); } throw new Error('"' + sortMode + '" is not a valid chunk sort mode'); }; diff --git a/lib/chunksorter.js b/lib/chunksorter.js index 3737add..75f1a11 100644 --- a/lib/chunksorter.js +++ b/lib/chunksorter.js @@ -80,6 +80,28 @@ module.exports.none = function (chunks) { return chunks; }; +/** + * Sort manually by the chunks + * @param {Array} chunks the chunks to sort + * @return {Array} The sorted chunks + */ +module.exports.manual = function (chunks, specifyChunks) { + var chunksResult = []; + var filterResult = []; + if (Array.isArray(specifyChunks)) { + for (var i = 0; i < specifyChunks.length; i++) { + filterResult = chunks.filter(function (chunk) { + if (chunk.names[0] && chunk.names[0] === specifyChunks[i]) { + return true; + } + return false; + }); + filterResult.length > 0 && chunksResult.push(filterResult[0]); + } + } + return chunksResult; +}; + /** * Defines the default sorter. */ diff --git a/spec/BasicSpec.js b/spec/BasicSpec.js index facf354..00291b8 100644 --- a/spec/BasicSpec.js +++ b/spec/BasicSpec.js @@ -1484,6 +1484,37 @@ describe('HtmlWebpackPlugin', function () { /