2017-03-26 15:41:52 +08:00
|
|
|
"use strict";
|
|
|
|
|
2018-09-05 20:22:10 +08:00
|
|
|
const webpack = require("../../../");
|
2017-03-26 15:41:52 +08:00
|
|
|
const RequestShortener = require("../../../lib/RequestShortener");
|
2019-10-16 22:38:04 +08:00
|
|
|
const { compareModulesByIdentifier } = require("../../../lib/util/comparators");
|
2017-03-26 15:41:52 +08:00
|
|
|
|
|
|
|
module.exports = {
|
2017-11-21 17:41:01 +08:00
|
|
|
mode: "production",
|
2018-12-07 19:26:35 +08:00
|
|
|
optimization: { chunkIds: false },
|
2017-03-26 15:41:52 +08:00
|
|
|
entry: {
|
2018-02-25 09:00:20 +08:00
|
|
|
entry: "./entry"
|
2017-03-26 15:41:52 +08:00
|
|
|
},
|
|
|
|
plugins: [
|
2018-09-05 20:22:10 +08:00
|
|
|
new webpack.ids.NamedChunkIdsPlugin((chunk, { chunkGraph }) => {
|
2018-02-25 09:00:20 +08:00
|
|
|
if (chunk.name) {
|
2017-03-26 15:41:52 +08:00
|
|
|
return chunk.name;
|
|
|
|
}
|
2018-02-25 09:00:20 +08:00
|
|
|
const chunkModulesToName = chunk =>
|
2018-08-14 17:18:22 +08:00
|
|
|
Array.from(
|
2018-08-16 22:11:20 +08:00
|
|
|
chunkGraph.getOrderedChunkModulesIterable(
|
|
|
|
chunk,
|
2019-10-16 22:38:04 +08:00
|
|
|
compareModulesByIdentifier
|
2018-08-16 22:11:20 +08:00
|
|
|
),
|
2018-08-14 17:18:22 +08:00
|
|
|
mod => {
|
|
|
|
const rs = new RequestShortener(mod.context);
|
|
|
|
return rs.shorten(mod.request).replace(/[./\\]/g, "_");
|
|
|
|
}
|
|
|
|
).join("-");
|
2017-03-26 15:41:52 +08:00
|
|
|
|
2018-08-14 17:18:22 +08:00
|
|
|
if (chunkGraph.getNumberOfChunkModules(chunk) > 0) {
|
2017-04-21 16:05:56 +08:00
|
|
|
return `chunk-containing-${chunkModulesToName(chunk)}`;
|
2017-03-26 15:41:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2018-02-25 09:00:20 +08:00
|
|
|
})
|
2017-03-26 15:41:52 +08:00
|
|
|
]
|
|
|
|
};
|