2014-02-05 19:05:09 +08:00
|
|
|
# pageA.js
|
|
|
|
|
2019-04-09 02:29:40 +08:00
|
|
|
```javascript
|
2014-02-05 19:05:09 +08:00
|
|
|
require(["./common"], function(common) {
|
|
|
|
common(require("./a"));
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
# pageB.js
|
|
|
|
|
2019-04-09 02:29:40 +08:00
|
|
|
```javascript
|
2014-02-05 19:05:09 +08:00
|
|
|
require(["./common"], function(common) {
|
|
|
|
common(require("./b"));
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
# pageC.js
|
|
|
|
|
2019-04-09 02:29:40 +08:00
|
|
|
```javascript
|
2014-02-05 20:12:20 +08:00
|
|
|
require(["./a"], function(a) {
|
|
|
|
console.log(a + require("./b"));
|
2014-02-05 19:05:09 +08:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
# common.js
|
|
|
|
|
|
|
|
a big file...
|
|
|
|
|
|
|
|
# webpack.config.js
|
|
|
|
|
2019-04-09 02:29:40 +08:00
|
|
|
```javascript
|
2014-02-05 19:05:09 +08:00
|
|
|
var path = require("path");
|
2019-10-11 05:11:05 +08:00
|
|
|
var { AggressiveMergingPlugin } = require("../../").optimize;
|
|
|
|
|
2014-02-05 19:05:09 +08:00
|
|
|
module.exports = {
|
2017-12-14 17:58:03 +08:00
|
|
|
// mode: "development" || "production",
|
2014-02-05 19:05:09 +08:00
|
|
|
entry: {
|
|
|
|
pageA: "./pageA",
|
|
|
|
pageB: "./pageB",
|
|
|
|
pageC: "./pageC"
|
|
|
|
},
|
|
|
|
output: {
|
2018-01-05 04:39:29 +08:00
|
|
|
path: path.join(__dirname, "dist"),
|
2014-02-05 19:05:09 +08:00
|
|
|
filename: "[name].bundle.js",
|
|
|
|
chunkFilename: "[id].chunk.js"
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new AggressiveMergingPlugin({
|
2018-01-20 00:06:59 +08:00
|
|
|
minSizeReduce: 1.5
|
2014-02-05 19:05:09 +08:00
|
|
|
})
|
2017-12-14 17:58:03 +08:00
|
|
|
],
|
|
|
|
optimization: {
|
2018-12-19 21:05:17 +08:00
|
|
|
chunkIds: "deterministic" // To keep filename consistent between different modes (for example building only)
|
2017-12-14 17:58:03 +08:00
|
|
|
}
|
2017-03-31 02:25:01 +08:00
|
|
|
};
|
2014-02-05 19:05:09 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
# Info
|
|
|
|
|
2017-12-14 17:58:03 +08:00
|
|
|
## Unoptimized
|
2014-02-05 19:05:09 +08:00
|
|
|
|
|
|
|
```
|
2020-12-11 17:29:32 +08:00
|
|
|
asset pageA.bundle.js 8.91 KiB [emitted] (name: pageA)
|
|
|
|
asset pageB.bundle.js 8.91 KiB [emitted] (name: pageB)
|
|
|
|
asset pageC.bundle.js 8.91 KiB [emitted] (name: pageC)
|
2020-09-21 04:39:12 +08:00
|
|
|
asset 456.chunk.js 6.28 KiB [emitted]
|
|
|
|
asset 394.chunk.js 606 bytes [emitted]
|
2021-08-20 14:12:50 +08:00
|
|
|
chunk (runtime: pageB) pageB.bundle.js (pageB) 69 bytes (javascript) 4.98 KiB (runtime) [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./pageB pageB
|
2021-08-20 14:12:50 +08:00
|
|
|
runtime modules 4.98 KiB 6 modules
|
2020-09-21 04:39:12 +08:00
|
|
|
./pageB.js 69 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
entry ./pageB pageB
|
2021-08-20 14:12:50 +08:00
|
|
|
chunk (runtime: pageC) pageC.bundle.js (pageC) 68 bytes (javascript) 4.98 KiB (runtime) [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./pageC pageC
|
2021-08-20 14:12:50 +08:00
|
|
|
runtime modules 4.98 KiB 6 modules
|
2020-09-21 04:39:12 +08:00
|
|
|
./pageC.js 68 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
entry ./pageC pageC
|
2020-12-11 17:29:32 +08:00
|
|
|
chunk (runtime: pageC) 394.chunk.js 42 bytes [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./a ./pageC.js 1:0-3:2
|
|
|
|
./a.js 21 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./a.js 1:0-14
|
|
|
|
cjs require ./a ./pageA.js 2:8-22
|
|
|
|
amd require ./a ./pageC.js 1:0-3:2
|
|
|
|
./b.js 21 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./b.js 1:0-14
|
|
|
|
cjs require ./b ./pageB.js 2:8-22
|
|
|
|
cjs require ./b ./pageC.js 2:17-31
|
2021-08-20 14:12:50 +08:00
|
|
|
chunk (runtime: pageA) pageA.bundle.js (pageA) 69 bytes (javascript) 4.98 KiB (runtime) [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./pageA pageA
|
2021-08-20 14:12:50 +08:00
|
|
|
runtime modules 4.98 KiB 6 modules
|
2020-09-21 04:39:12 +08:00
|
|
|
./pageA.js 69 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
entry ./pageA pageA
|
2020-12-11 17:29:32 +08:00
|
|
|
chunk (runtime: pageA, pageB) 456.chunk.js 5.45 KiB [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./common ./pageA.js 1:0-3:2
|
|
|
|
> ./common ./pageB.js 1:0-3:2
|
|
|
|
./a.js 21 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./a.js 1:0-14
|
|
|
|
cjs require ./a ./pageA.js 2:8-22
|
|
|
|
amd require ./a ./pageC.js 1:0-3:2
|
|
|
|
./b.js 21 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./b.js 1:0-14
|
|
|
|
cjs require ./b ./pageB.js 2:8-22
|
|
|
|
cjs require ./b ./pageC.js 2:17-31
|
|
|
|
./common.js 5.41 KiB [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./common.js 1:0-14
|
|
|
|
amd require ./common ./pageA.js 1:0-3:2
|
|
|
|
amd require ./common ./pageB.js 1:0-3:2
|
2021-08-20 14:12:50 +08:00
|
|
|
webpack 5.51.1 compiled successfully
|
2014-02-05 19:05:09 +08:00
|
|
|
```
|
|
|
|
|
2017-12-14 17:58:03 +08:00
|
|
|
## Production mode
|
2014-02-05 19:05:09 +08:00
|
|
|
|
|
|
|
```
|
2021-08-20 14:12:50 +08:00
|
|
|
asset pageC.bundle.js 1.74 KiB [emitted] [minimized] (name: pageC)
|
|
|
|
asset pageA.bundle.js 1.73 KiB [emitted] [minimized] (name: pageA)
|
|
|
|
asset pageB.bundle.js 1.73 KiB [emitted] [minimized] (name: pageB)
|
2020-09-21 04:39:12 +08:00
|
|
|
asset 456.chunk.js 155 bytes [emitted] [minimized]
|
|
|
|
asset 394.chunk.js 104 bytes [emitted] [minimized]
|
2021-08-20 14:12:50 +08:00
|
|
|
chunk (runtime: pageB) pageB.bundle.js (pageB) 69 bytes (javascript) 4.98 KiB (runtime) [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./pageB pageB
|
2021-08-20 14:12:50 +08:00
|
|
|
runtime modules 4.98 KiB 6 modules
|
2020-09-21 04:39:12 +08:00
|
|
|
./pageB.js 69 bytes [built] [code generated]
|
|
|
|
[no exports used]
|
|
|
|
entry ./pageB pageB
|
2021-08-20 14:12:50 +08:00
|
|
|
chunk (runtime: pageC) pageC.bundle.js (pageC) 68 bytes (javascript) 4.98 KiB (runtime) [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./pageC pageC
|
2021-08-20 14:12:50 +08:00
|
|
|
runtime modules 4.98 KiB 6 modules
|
2020-09-21 04:39:12 +08:00
|
|
|
./pageC.js 68 bytes [built] [code generated]
|
|
|
|
[no exports used]
|
|
|
|
entry ./pageC pageC
|
|
|
|
chunk (runtime: pageC) 394.chunk.js 42 bytes [rendered]
|
|
|
|
> ./a ./pageC.js 1:0-3:2
|
|
|
|
./a.js 21 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./a.js 1:0-14
|
|
|
|
cjs require ./a ./pageA.js 2:8-22
|
|
|
|
amd require ./a ./pageC.js 1:0-3:2
|
|
|
|
./b.js 21 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./b.js 1:0-14
|
|
|
|
cjs require ./b ./pageB.js 2:8-22
|
|
|
|
cjs require ./b ./pageC.js 2:17-31
|
2021-08-20 14:12:50 +08:00
|
|
|
chunk (runtime: pageA) pageA.bundle.js (pageA) 69 bytes (javascript) 4.98 KiB (runtime) [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./pageA pageA
|
2021-08-20 14:12:50 +08:00
|
|
|
runtime modules 4.98 KiB 6 modules
|
2020-09-21 04:39:12 +08:00
|
|
|
./pageA.js 69 bytes [built] [code generated]
|
|
|
|
[no exports used]
|
|
|
|
entry ./pageA pageA
|
|
|
|
chunk (runtime: pageA, pageB) 456.chunk.js 5.45 KiB [rendered]
|
|
|
|
> ./common ./pageA.js 1:0-3:2
|
|
|
|
> ./common ./pageB.js 1:0-3:2
|
|
|
|
./a.js 21 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./a.js 1:0-14
|
|
|
|
cjs require ./a ./pageA.js 2:8-22
|
|
|
|
amd require ./a ./pageC.js 1:0-3:2
|
|
|
|
./b.js 21 bytes [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./b.js 1:0-14
|
|
|
|
cjs require ./b ./pageB.js 2:8-22
|
|
|
|
cjs require ./b ./pageC.js 2:17-31
|
|
|
|
./common.js 5.41 KiB [built] [code generated]
|
|
|
|
[used exports unknown]
|
|
|
|
cjs self exports reference ./common.js 1:0-14
|
|
|
|
amd require ./common ./pageA.js 1:0-3:2
|
|
|
|
amd require ./common ./pageB.js 1:0-3:2
|
2021-08-20 14:12:50 +08:00
|
|
|
webpack 5.51.1 compiled successfully
|
2014-02-05 19:05:09 +08:00
|
|
|
```
|