mirror of https://github.com/webpack/webpack.git
4.20.2 |
||
---|---|---|
.. | ||
README.md | ||
a.js | ||
b.js | ||
build.js | ||
common.js | ||
pageA.js | ||
pageB.js | ||
pageC.js | ||
template.md | ||
webpack.config.js |
README.md
pageA.js
require(["./common"], function(common) {
common(require("./a"));
});
pageB.js
require(["./common"], function(common) {
common(require("./b"));
});
pageC.js
require(["./a"], function(a) {
console.log(a + require("./b"));
});
common.js
a big file...
webpack.config.js
var path = require("path");
var AggressiveMergingPlugin = require("../../lib/optimize/AggressiveMergingPlugin");
module.exports = {
// mode: "development" || "production",
entry: {
pageA: "./pageA",
pageB: "./pageB",
pageC: "./pageC"
},
output: {
path: path.join(__dirname, "dist"),
filename: "[name].bundle.js",
chunkFilename: "[id].chunk.js"
},
plugins: [
new AggressiveMergingPlugin({
minSizeReduce: 1.5
})
],
optimization: {
chunkIds: "total-size" // To keep filename consistent between different modes (for example building only)
}
};
Info
Unoptimized
Hash: 0a1b2c3d4e5f6a7b8c9d
Version: webpack 5.0.0-next
Asset Size Chunks Chunk Names
0.chunk.js 6 KiB 0 [emitted]
4.chunk.js 410 bytes 4 [emitted]
pageA.bundle.js 8.33 KiB 1 [emitted] pageA
pageB.bundle.js 8.34 KiB 2 [emitted] pageB
pageC.bundle.js 8.33 KiB 3 [emitted] pageC
Entrypoint pageA = pageA.bundle.js
Entrypoint pageB = pageB.bundle.js
Entrypoint pageC = pageC.bundle.js
chunk {0} 0.chunk.js 5.46 KiB <{1}> <{2}> [rendered]
> ./common [0] ./pageA.js 1:0-3:2
> ./common [1] ./pageB.js 1:0-3:2
[3] ./common.js 5.42 KiB {0} [built]
[used exports unknown]
amd require ./common [0] ./pageA.js 1:0-3:2
amd require ./common [1] ./pageB.js 1:0-3:2
[4] ./a.js 21 bytes {0} {4} [built]
[used exports unknown]
cjs require ./a [0] ./pageA.js 2:8-22
amd require ./a [2] ./pageC.js 1:0-3:2
[5] ./b.js 21 bytes {0} {4} [built]
[used exports unknown]
cjs require ./b [1] ./pageB.js 2:8-22
cjs require ./b [2] ./pageC.js 2:17-31
chunk {1} pageA.bundle.js (pageA) 71 bytes >{0}< [entry] [rendered]
> ./pageA pageA
[0] ./pageA.js 71 bytes {1} [built]
[used exports unknown]
entry ./pageA pageA
chunk {2} pageB.bundle.js (pageB) 71 bytes >{0}< [entry] [rendered]
> ./pageB pageB
[1] ./pageB.js 71 bytes {2} [built]
[used exports unknown]
entry ./pageB pageB
chunk {3} pageC.bundle.js (pageC) 70 bytes >{4}< [entry] [rendered]
> ./pageC pageC
[2] ./pageC.js 70 bytes {3} [built]
[used exports unknown]
entry ./pageC pageC
chunk {4} 4.chunk.js 42 bytes <{3}> [rendered]
> ./a [2] ./pageC.js 1:0-3:2
[4] ./a.js 21 bytes {0} {4} [built]
[used exports unknown]
cjs require ./a [0] ./pageA.js 2:8-22
amd require ./a [2] ./pageC.js 1:0-3:2
[5] ./b.js 21 bytes {0} {4} [built]
[used exports unknown]
cjs require ./b [1] ./pageB.js 2:8-22
cjs require ./b [2] ./pageC.js 2:17-31
Production mode
Hash: 0a1b2c3d4e5f6a7b8c9d
Version: webpack 5.0.0-next
Asset Size Chunks Chunk Names
0.chunk.js 173 bytes 0, 1 [emitted]
1.chunk.js 118 bytes 1 [emitted]
pageA.bundle.js 2.06 KiB 2 [emitted] pageA
pageB.bundle.js 2.06 KiB 3 [emitted] pageB
pageC.bundle.js 2.08 KiB 4 [emitted] pageC
Entrypoint pageA = pageA.bundle.js
Entrypoint pageB = pageB.bundle.js
Entrypoint pageC = pageC.bundle.js
chunk {0} 0.chunk.js 5.46 KiB <{2}> <{3}> [rendered]
> ./common [3] ./pageA.js 1:0-3:2
> ./common [4] ./pageB.js 1:0-3:2
[0] ./a.js 21 bytes {0} {1} [built]
cjs require ./a [3] ./pageA.js 2:8-22
amd require ./a [5] ./pageC.js 1:0-3:2
[1] ./b.js 21 bytes {0} {1} [built]
cjs require ./b [4] ./pageB.js 2:8-22
cjs require ./b [5] ./pageC.js 2:17-31
[2] ./common.js 5.42 KiB {0} [built]
amd require ./common [3] ./pageA.js 1:0-3:2
amd require ./common [4] ./pageB.js 1:0-3:2
chunk {1} 1.chunk.js 42 bytes <{4}> [rendered]
> ./a [5] ./pageC.js 1:0-3:2
[0] ./a.js 21 bytes {0} {1} [built]
cjs require ./a [3] ./pageA.js 2:8-22
amd require ./a [5] ./pageC.js 1:0-3:2
[1] ./b.js 21 bytes {0} {1} [built]
cjs require ./b [4] ./pageB.js 2:8-22
cjs require ./b [5] ./pageC.js 2:17-31
chunk {2} pageA.bundle.js (pageA) 71 bytes >{0}< [entry] [rendered]
> ./pageA pageA
[3] ./pageA.js 71 bytes {2} [built]
entry ./pageA pageA
chunk {3} pageB.bundle.js (pageB) 71 bytes >{0}< [entry] [rendered]
> ./pageB pageB
[4] ./pageB.js 71 bytes {3} [built]
entry ./pageB pageB
chunk {4} pageC.bundle.js (pageC) 70 bytes >{1}< [entry] [rendered]
> ./pageC pageC
[5] ./pageC.js 70 bytes {4} [built]
entry ./pageC pageC