2015-04-28 22:58:01 +08:00
|
|
|
# webpack.config.js
|
|
|
|
|
2019-04-09 02:29:40 +08:00
|
|
|
```javascript
|
2015-04-28 22:58:01 +08:00
|
|
|
var path = require("path");
|
2016-09-14 18:04:42 +08:00
|
|
|
var webpack = require("../../");
|
|
|
|
module.exports = [
|
|
|
|
{
|
|
|
|
name: "vendor",
|
2017-12-14 17:58:03 +08:00
|
|
|
// mode: "development || "production",
|
2016-09-14 18:04:42 +08:00
|
|
|
entry: ["./vendor", "./vendor2"],
|
|
|
|
output: {
|
2018-01-05 04:39:29 +08:00
|
|
|
path: path.resolve(__dirname, "dist"),
|
2016-09-14 18:04:42 +08:00
|
|
|
filename: "vendor.js",
|
2019-01-28 09:27:57 +08:00
|
|
|
library: "vendor_[fullhash]"
|
2016-09-14 18:04:42 +08:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.DllPlugin({
|
2019-01-28 09:27:57 +08:00
|
|
|
name: "vendor_[fullhash]",
|
2018-01-06 16:44:17 +08:00
|
|
|
path: path.resolve(__dirname, "dist/manifest.json")
|
2016-09-14 18:04:42 +08:00
|
|
|
})
|
|
|
|
]
|
2015-04-28 22:58:01 +08:00
|
|
|
},
|
2018-01-22 22:18:54 +08:00
|
|
|
|
2016-09-14 18:04:42 +08:00
|
|
|
{
|
|
|
|
name: "app",
|
2017-12-14 17:58:03 +08:00
|
|
|
// mode: "development || "production",
|
2016-09-14 18:04:42 +08:00
|
|
|
dependencies: ["vendor"],
|
|
|
|
entry: {
|
|
|
|
pageA: "./pageA",
|
|
|
|
pageB: "./pageB",
|
|
|
|
pageC: "./pageC"
|
|
|
|
},
|
|
|
|
output: {
|
2018-01-05 04:39:29 +08:00
|
|
|
path: path.join(__dirname, "dist"),
|
2016-09-14 18:04:42 +08:00
|
|
|
filename: "[name].js"
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.DllReferencePlugin({
|
2018-01-06 16:44:17 +08:00
|
|
|
manifest: path.resolve(__dirname, "dist/manifest.json")
|
2016-09-14 18:04:42 +08:00
|
|
|
})
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
2015-04-28 22:58:01 +08:00
|
|
|
```
|
|
|
|
|
2018-01-05 04:39:29 +08:00
|
|
|
# dist/vendor.js
|
2015-04-28 22:58:01 +08:00
|
|
|
|
2019-04-09 02:29:40 +08:00
|
|
|
```javascript
|
2021-08-20 14:12:50 +08:00
|
|
|
var vendor_5993716ff0c3ad2aef3c;
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ (() => { // webpackBootstrap
|
|
|
|
/******/ var __webpack_modules__ = ([
|
2015-04-28 22:58:01 +08:00
|
|
|
/* 0 */
|
2017-06-05 22:12:12 +08:00
|
|
|
/*!****************!*\
|
|
|
|
!*** dll main ***!
|
|
|
|
\****************/
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! unknown exports (runtime-defined) */
|
2019-08-05 19:32:25 +08:00
|
|
|
/*! runtime requirements: __webpack_require__, module */
|
2019-10-11 05:11:05 +08:00
|
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
2017-06-05 22:12:12 +08:00
|
|
|
|
|
|
|
module.exports = __webpack_require__;
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 1 */
|
2015-04-28 22:58:01 +08:00
|
|
|
/*!*******************!*\
|
|
|
|
!*** ./vendor.js ***!
|
|
|
|
\*******************/
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! unknown exports (runtime-defined) */
|
2018-12-19 21:05:17 +08:00
|
|
|
/*! runtime requirements: module */
|
2020-09-21 04:39:12 +08:00
|
|
|
/*! CommonJS bailout: module.exports is used directly at 1:0-14 */
|
2019-10-09 05:45:47 +08:00
|
|
|
/***/ ((module) => {
|
2015-04-28 22:58:01 +08:00
|
|
|
|
2016-09-07 18:28:56 +08:00
|
|
|
module.exports = "Vendor";
|
2015-04-28 22:58:01 +08:00
|
|
|
|
2017-03-31 02:25:01 +08:00
|
|
|
/***/ }),
|
2017-06-05 22:12:12 +08:00
|
|
|
/* 2 */
|
2016-02-04 07:27:47 +08:00
|
|
|
/*!********************!*\
|
2016-09-14 18:04:42 +08:00
|
|
|
!*** ./vendor2.js ***!
|
2016-02-04 07:27:47 +08:00
|
|
|
\********************/
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! unknown exports (runtime-defined) */
|
2018-12-19 21:05:17 +08:00
|
|
|
/*! runtime requirements: module */
|
2020-09-21 04:39:12 +08:00
|
|
|
/*! CommonJS bailout: module.exports is used directly at 1:0-14 */
|
2019-10-09 05:45:47 +08:00
|
|
|
/***/ ((module) => {
|
2016-02-04 07:27:47 +08:00
|
|
|
|
2016-09-14 18:04:42 +08:00
|
|
|
module.exports = "Vendor2";
|
|
|
|
|
2017-03-31 02:25:01 +08:00
|
|
|
/***/ })
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ ]);
|
2019-11-19 21:10:28 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
<details><summary><code>/* webpack runtime code */</code></summary>
|
|
|
|
|
|
|
|
``` js
|
2019-10-11 05:11:05 +08:00
|
|
|
/************************************************************************/
|
2016-09-14 18:04:42 +08:00
|
|
|
/******/ // The module cache
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ var __webpack_module_cache__ = {};
|
|
|
|
/******/
|
2016-09-14 18:04:42 +08:00
|
|
|
/******/ // The require function
|
|
|
|
/******/ function __webpack_require__(moduleId) {
|
|
|
|
/******/ // Check if module is in cache
|
2021-08-20 14:12:50 +08:00
|
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
|
|
/******/ if (cachedModule !== undefined) {
|
|
|
|
/******/ return cachedModule.exports;
|
2017-05-23 04:45:18 +08:00
|
|
|
/******/ }
|
2016-09-14 18:04:42 +08:00
|
|
|
/******/ // Create a new module (and put it into the cache)
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
2020-05-21 05:26:51 +08:00
|
|
|
/******/ // no module.id needed
|
|
|
|
/******/ // no module.loaded needed
|
2016-09-14 18:04:42 +08:00
|
|
|
/******/ exports: {}
|
|
|
|
/******/ };
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/
|
2016-09-14 18:04:42 +08:00
|
|
|
/******/ // Execute the module function
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
|
|
/******/
|
2016-09-14 18:04:42 +08:00
|
|
|
/******/ // Return the exports of the module
|
|
|
|
/******/ return module.exports;
|
|
|
|
/******/ }
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/
|
2016-09-14 18:04:42 +08:00
|
|
|
/************************************************************************/
|
2019-11-19 21:10:28 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
``` js
|
2021-08-20 14:12:50 +08:00
|
|
|
/******/
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ // startup
|
|
|
|
/******/ // Load entry module and return exports
|
2021-08-20 14:12:50 +08:00
|
|
|
/******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined
|
|
|
|
/******/ var __webpack_exports__ = __webpack_require__(0);
|
|
|
|
/******/ vendor_5993716ff0c3ad2aef3c = __webpack_exports__;
|
|
|
|
/******/
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ })()
|
|
|
|
;
|
|
|
|
```
|
|
|
|
|
|
|
|
# dist/pageA.js
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
/******/ (() => { // webpackBootstrap
|
|
|
|
/******/ var __webpack_modules__ = ([
|
2016-09-14 18:04:42 +08:00
|
|
|
/* 0 */
|
2015-04-28 22:58:01 +08:00
|
|
|
/*!******************!*\
|
|
|
|
!*** ./pageA.js ***!
|
|
|
|
\******************/
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! unknown exports (runtime-defined) */
|
|
|
|
/*! runtime requirements: module, __webpack_require__ */
|
2020-09-21 04:39:12 +08:00
|
|
|
/*! CommonJS bailout: module.exports is used directly at 2:0-14 */
|
2019-10-11 05:11:05 +08:00
|
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
2015-04-28 22:58:01 +08:00
|
|
|
|
2017-12-14 17:58:03 +08:00
|
|
|
console.log(__webpack_require__(/*! ./vendor */ 1));
|
2016-09-07 18:28:56 +08:00
|
|
|
module.exports = "pageA";
|
2015-04-28 22:58:01 +08:00
|
|
|
|
2017-06-05 22:12:12 +08:00
|
|
|
/***/ }),
|
2017-12-14 17:58:03 +08:00
|
|
|
/* 1 */
|
2017-06-05 22:12:12 +08:00
|
|
|
/*!****************************************************************************!*\
|
2021-08-20 14:12:50 +08:00
|
|
|
!*** delegated ./vendor.js from dll-reference vendor_5993716ff0c3ad2aef3c ***!
|
2017-06-05 22:12:12 +08:00
|
|
|
\****************************************************************************/
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! unknown exports (runtime-defined) */
|
2019-08-05 19:32:25 +08:00
|
|
|
/*! runtime requirements: module, __webpack_require__ */
|
2019-10-11 05:11:05 +08:00
|
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
2017-06-05 22:12:12 +08:00
|
|
|
|
2021-08-20 14:12:50 +08:00
|
|
|
module.exports = (__webpack_require__(/*! dll-reference vendor_5993716ff0c3ad2aef3c */ 2))(1);
|
2017-12-14 17:58:03 +08:00
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 2 */
|
|
|
|
/*!**********************************************!*\
|
2021-08-20 14:12:50 +08:00
|
|
|
!*** external "vendor_5993716ff0c3ad2aef3c" ***!
|
2017-12-14 17:58:03 +08:00
|
|
|
\**********************************************/
|
2020-09-21 04:39:12 +08:00
|
|
|
/*! dynamic exports */
|
|
|
|
/*! exports [maybe provided (runtime-defined)] [no usage info] */
|
2018-12-19 21:05:17 +08:00
|
|
|
/*! runtime requirements: module */
|
2019-10-09 05:45:47 +08:00
|
|
|
/***/ ((module) => {
|
2017-12-14 17:58:03 +08:00
|
|
|
|
2019-10-11 05:11:05 +08:00
|
|
|
"use strict";
|
2021-08-20 14:12:50 +08:00
|
|
|
module.exports = vendor_5993716ff0c3ad2aef3c;
|
2017-06-05 22:12:12 +08:00
|
|
|
|
2017-03-31 02:25:01 +08:00
|
|
|
/***/ })
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ ]);
|
2019-11-19 21:10:28 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
<details><summary><code>/* webpack runtime code */</code></summary>
|
|
|
|
|
|
|
|
``` js
|
2019-10-11 05:11:05 +08:00
|
|
|
/************************************************************************/
|
|
|
|
/******/ // The module cache
|
|
|
|
/******/ var __webpack_module_cache__ = {};
|
|
|
|
/******/
|
|
|
|
/******/ // The require function
|
|
|
|
/******/ function __webpack_require__(moduleId) {
|
|
|
|
/******/ // Check if module is in cache
|
2021-08-20 14:12:50 +08:00
|
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
|
|
/******/ if (cachedModule !== undefined) {
|
|
|
|
/******/ return cachedModule.exports;
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ }
|
|
|
|
/******/ // Create a new module (and put it into the cache)
|
|
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
2020-05-21 05:26:51 +08:00
|
|
|
/******/ // no module.id needed
|
|
|
|
/******/ // no module.loaded needed
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ exports: {}
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
/******/ // Execute the module function
|
|
|
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
|
|
/******/
|
|
|
|
/******/ // Return the exports of the module
|
|
|
|
/******/ return module.exports;
|
|
|
|
/******/ }
|
|
|
|
/******/
|
|
|
|
/************************************************************************/
|
2019-11-19 21:10:28 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
``` js
|
2021-08-20 14:12:50 +08:00
|
|
|
/******/
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ // startup
|
2021-08-20 14:12:50 +08:00
|
|
|
/******/ // Load entry module and return exports
|
2020-12-11 17:29:32 +08:00
|
|
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
2021-08-20 14:12:50 +08:00
|
|
|
/******/ var __webpack_exports__ = __webpack_require__(0);
|
|
|
|
/******/
|
2019-10-11 05:11:05 +08:00
|
|
|
/******/ })()
|
|
|
|
;
|
2015-04-28 22:58:01 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
# Info
|
|
|
|
|
2017-12-14 17:58:03 +08:00
|
|
|
## Unoptimized
|
2015-04-28 22:58:01 +08:00
|
|
|
|
|
|
|
```
|
2020-09-21 04:39:12 +08:00
|
|
|
vendor:
|
2021-08-20 14:12:50 +08:00
|
|
|
asset vendor.js 2.28 KiB [emitted] (name: main)
|
2020-12-11 17:29:32 +08:00
|
|
|
chunk (runtime: main) vendor.js (main) 65 bytes [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> main
|
|
|
|
dependent modules 53 bytes [dependent] 2 modules
|
|
|
|
dll main 12 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
dll entry
|
|
|
|
used as library export
|
2021-08-20 14:12:50 +08:00
|
|
|
vendor (webpack 5.51.1) compiled successfully
|
2020-09-21 04:39:12 +08:00
|
|
|
|
|
|
|
app:
|
2021-08-20 14:12:50 +08:00
|
|
|
asset pageB.js 2.63 KiB [emitted] (name: pageB)
|
|
|
|
asset pageA.js 2.61 KiB [emitted] (name: pageA)
|
|
|
|
asset pageC.js 1.61 KiB [emitted] (name: pageC)
|
2020-12-11 17:29:32 +08:00
|
|
|
chunk (runtime: pageA) pageA.js (pageA) 143 bytes [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./pageA pageA
|
|
|
|
dependent modules 84 bytes [dependent] 2 modules
|
|
|
|
./pageA.js 59 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./pageA.js 2:0-14
|
|
|
|
entry ./pageA pageA
|
2020-12-11 17:29:32 +08:00
|
|
|
chunk (runtime: pageB) pageB.js (pageB) 144 bytes [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./pageB pageB
|
|
|
|
dependent modules 84 bytes [dependent] 2 modules
|
|
|
|
./pageB.js 60 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./pageB.js 2:0-14
|
|
|
|
entry ./pageB pageB
|
2020-12-11 17:29:32 +08:00
|
|
|
chunk (runtime: pageC) pageC.js (pageC) 25 bytes [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./pageC pageC
|
|
|
|
./pageC.js 25 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./pageC.js 1:0-14
|
|
|
|
entry ./pageC pageC
|
2021-08-20 14:12:50 +08:00
|
|
|
app (webpack 5.51.1) compiled successfully
|
2015-04-28 22:58:01 +08:00
|
|
|
```
|
|
|
|
|
2017-12-14 17:58:03 +08:00
|
|
|
## Production mode
|
2015-04-28 22:58:01 +08:00
|
|
|
|
|
|
|
```
|
2020-09-21 04:39:12 +08:00
|
|
|
vendor:
|
2021-08-20 14:12:50 +08:00
|
|
|
asset vendor.js 294 bytes [emitted] [minimized] (name: main)
|
2020-09-21 04:39:12 +08:00
|
|
|
chunk (runtime: main) vendor.js (main) 65 bytes [entry] [rendered]
|
|
|
|
> main
|
|
|
|
dependent modules 53 bytes [dependent] 2 modules
|
|
|
|
dll main 12 bytes [built] [code generated]
|
|
|
|
dll entry
|
|
|
|
used as library export
|
2021-08-20 14:12:50 +08:00
|
|
|
vendor (webpack 5.51.1) compiled successfully
|
2020-09-21 04:39:12 +08:00
|
|
|
|
|
|
|
app:
|
2021-08-20 14:12:50 +08:00
|
|
|
asset pageA.js 297 bytes [emitted] [minimized] (name: pageA)
|
|
|
|
asset pageB.js 297 bytes [emitted] [minimized] (name: pageB)
|
|
|
|
asset pageC.js 174 bytes [emitted] [minimized] (name: pageC)
|
2020-09-21 04:39:12 +08:00
|
|
|
chunk (runtime: pageB) pageB.js (pageB) 144 bytes [entry] [rendered]
|
|
|
|
> ./pageB pageB
|
|
|
|
dependent modules 84 bytes [dependent] 2 modules
|
|
|
|
./pageB.js 60 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./pageB.js 2:0-14
|
|
|
|
entry ./pageB pageB
|
|
|
|
chunk (runtime: pageC) pageC.js (pageC) 25 bytes [entry] [rendered]
|
|
|
|
> ./pageC pageC
|
|
|
|
./pageC.js 25 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./pageC.js 1:0-14
|
|
|
|
entry ./pageC pageC
|
|
|
|
chunk (runtime: pageA) pageA.js (pageA) 143 bytes [entry] [rendered]
|
|
|
|
> ./pageA pageA
|
|
|
|
dependent modules 84 bytes [dependent] 2 modules
|
|
|
|
./pageA.js 59 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./pageA.js 2:0-14
|
|
|
|
entry ./pageA pageA
|
2021-08-20 14:12:50 +08:00
|
|
|
app (webpack 5.51.1) compiled successfully
|
2015-04-28 22:58:01 +08:00
|
|
|
```
|