webpack/examples/dll/README.md

239 lines
6.3 KiB
Markdown
Raw Normal View History

2015-05-17 00:27:59 +08:00
# webpack.config.js
``` javascript
var path = require("path");
2015-06-13 23:41:14 +08:00
var webpack = require("../../");
2015-05-17 00:27:59 +08:00
module.exports = {
2016-09-07 20:57:53 +08:00
resolve: {
extensions: ['.js', '.jsx']
},
2015-05-17 00:27:59 +08:00
entry: {
2015-10-13 22:19:11 +08:00
alpha: ["./alpha", "./a", "module"],
2016-09-07 20:57:53 +08:00
beta: ["./beta", "./b", "./c"]
2015-05-17 00:27:59 +08:00
},
output: {
path: path.join(__dirname, "js"),
filename: "MyDll.[name].js",
library: "[name]_[hash]"
},
plugins: [
2015-06-13 23:41:14 +08:00
new webpack.DllPlugin({
2015-05-17 00:27:59 +08:00
path: path.join(__dirname, "js", "[name]-manifest.json"),
name: "[name]_[hash]"
})
]
};
```
# js/MyDll.alpha.js
``` javascript
2016-09-07 20:57:53 +08:00
var alpha_282e8826843b2bb4eeb1 =
2016-12-14 19:03:24 +08:00
```
<details><summary>`/******/ (function(modules) { /* webpackBootstrap */ })`</summary>
``` js
2015-05-17 00:27:59 +08:00
/******/ (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] = {
2016-06-06 02:51:44 +08:00
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
2015-05-17 00:27:59 +08:00
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
2016-06-06 02:51:44 +08:00
/******/ module.l = true;
2015-05-17 00:27:59 +08:00
/******/ // 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;
2016-12-08 02:14:47 +08:00
/******/ // identity function for calling harmony imports with the correct context
2016-06-06 02:51:44 +08:00
/******/ __webpack_require__.i = function(value) { return value; };
2016-12-08 02:14:47 +08:00
/******/ // define getter function for harmony exports
2016-09-07 18:28:56 +08:00
/******/ __webpack_require__.d = function(exports, name, getter) {
2016-12-14 19:03:24 +08:00
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
2016-09-07 18:28:56 +08:00
/******/ };
/******/ // 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); };
2015-05-17 00:27:59 +08:00
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "js/";
2016-02-04 20:02:53 +08:00
2015-05-17 00:27:59 +08:00
/******/ // Load entry module and return exports
2016-09-07 20:57:53 +08:00
/******/ return __webpack_require__(__webpack_require__.s = 6);
2015-05-17 00:27:59 +08:00
/******/ })
/************************************************************************/
2016-12-14 19:03:24 +08:00
```
</details>
``` js
2015-05-17 00:27:59 +08:00
/******/ ([
/* 0 */
2016-09-07 18:28:56 +08:00
/* unknown exports provided */
/* all exports used */
2016-02-04 07:27:47 +08:00
/*!**************!*\
!*** ./a.js ***!
\**************/
/***/ function(module, exports) {
2015-05-17 00:27:59 +08:00
2016-09-07 18:28:56 +08:00
module.exports = "a";
2015-05-17 00:27:59 +08:00
/***/ },
/* 1 */
2016-09-07 18:28:56 +08:00
/* unknown exports provided */
/* all exports used */
2015-05-17 00:27:59 +08:00
/*!******************!*\
!*** ./alpha.js ***!
\******************/
2015-06-13 23:41:14 +08:00
/***/ function(module, exports) {
2015-05-17 00:27:59 +08:00
2016-09-07 18:28:56 +08:00
module.exports = "alpha";
2015-05-17 00:27:59 +08:00
/***/ },
2016-02-04 07:27:47 +08:00
/* 2 */,
/* 3 */,
2016-09-07 20:57:53 +08:00
/* 4 */,
/* 5 */
2016-09-07 18:28:56 +08:00
/* unknown exports provided */
/* all exports used */
2015-10-13 22:19:11 +08:00
/*!**********************!*\
!*** ../~/module.js ***!
\**********************/
/***/ function(module, exports) {
2016-09-07 18:28:56 +08:00
module.exports = "module";
2015-10-13 22:19:11 +08:00
2016-02-04 07:27:47 +08:00
/***/ },
2016-09-07 20:57:53 +08:00
/* 6 */
2016-09-07 18:28:56 +08:00
/* unknown exports provided */
/* all exports used */
2016-02-04 07:27:47 +08:00
/*!*****************!*\
!*** dll alpha ***!
\*****************/
/***/ function(module, exports, __webpack_require__) {
2016-09-07 18:28:56 +08:00
module.exports = __webpack_require__;
2016-02-04 07:27:47 +08:00
2015-05-17 00:27:59 +08:00
/***/ }
/******/ ]);
```
2015-05-17 17:06:35 +08:00
# js/alpha-manifest.json
2015-05-17 00:27:59 +08:00
``` javascript
2015-05-17 17:06:35 +08:00
{
2016-09-07 20:57:53 +08:00
"name": "alpha_282e8826843b2bb4eeb1",
2015-05-17 17:06:35 +08:00
"content": {
2016-09-07 18:28:56 +08:00
"./a.js": {
"id": 0,
"meta": {}
},
"./alpha.js": {
"id": 1,
"meta": {}
},
"../node_modules/module.js": {
2016-09-07 20:57:53 +08:00
"id": 5,
2016-09-07 18:28:56 +08:00
"meta": {}
}
2015-05-17 17:06:35 +08:00
}
}
2015-05-17 00:27:59 +08:00
```
# Info
## Uncompressed
```
2016-09-07 20:57:53 +08:00
Hash: 282e8826843b2bb4eeb1
2016-12-14 19:03:24 +08:00
Version: webpack 2.2.0-rc.2
2015-05-17 00:27:59 +08:00
Asset Size Chunks Chunk Names
2016-12-14 19:03:24 +08:00
MyDll.beta.js 3.34 kB 0 [emitted] beta
MyDll.alpha.js 3.36 kB 1 [emitted] alpha
2016-09-07 18:28:56 +08:00
Entrypoint alpha = MyDll.alpha.js
Entrypoint beta = MyDll.beta.js
2016-09-07 20:57:53 +08:00
chunk {0} MyDll.beta.js (beta) 80 bytes [entry] [rendered]
> beta [7] dll beta
[2] ./b.js 21 bytes {0} [built]
single entry ./b [7] dll beta
[3] ./beta.js 24 bytes {0} [built]
single entry ./beta [7] dll beta
[4] ./c.jsx 23 bytes {0} [built]
single entry ./c [7] dll beta
[7] dll beta 12 bytes {0} [built]
chunk {1} MyDll.alpha.js (alpha) 84 bytes [entry] [rendered]
> alpha [6] dll alpha
[0] ./a.js 21 bytes {1} [built]
single entry ./a [6] dll alpha
[1] ./alpha.js 25 bytes {1} [built]
single entry ./alpha [6] dll alpha
[5] ../~/module.js 26 bytes {1} [built]
single entry module [6] dll alpha
[6] dll alpha 12 bytes {1} [built]
2015-05-17 00:27:59 +08:00
```
## Minimized (uglify-js, no zip)
```
2016-09-07 20:57:53 +08:00
Hash: 282e8826843b2bb4eeb1
2016-12-14 19:03:24 +08:00
Version: webpack 2.2.0-rc.2
2015-05-17 00:27:59 +08:00
Asset Size Chunks Chunk Names
2016-12-14 19:03:24 +08:00
MyDll.beta.js 653 bytes 0 [emitted] beta
MyDll.alpha.js 657 bytes 1 [emitted] alpha
2016-09-07 18:28:56 +08:00
Entrypoint alpha = MyDll.alpha.js
Entrypoint beta = MyDll.beta.js
2016-09-07 20:57:53 +08:00
chunk {0} MyDll.beta.js (beta) 80 bytes [entry] [rendered]
> beta [7] dll beta
[2] ./b.js 21 bytes {0} [built]
single entry ./b [7] dll beta
[3] ./beta.js 24 bytes {0} [built]
single entry ./beta [7] dll beta
[4] ./c.jsx 23 bytes {0} [built]
single entry ./c [7] dll beta
[7] dll beta 12 bytes {0} [built]
chunk {1} MyDll.alpha.js (alpha) 84 bytes [entry] [rendered]
> alpha [6] dll alpha
[0] ./a.js 21 bytes {1} [built]
single entry ./a [6] dll alpha
[1] ./alpha.js 25 bytes {1} [built]
single entry ./alpha [6] dll alpha
[5] ../~/module.js 26 bytes {1} [built]
single entry module [6] dll alpha
[6] dll alpha 12 bytes {1} [built]
2016-12-14 19:03:24 +08:00
```