mirror of https://github.com/webpack/webpack.git
38 lines
894 B
JavaScript
38 lines
894 B
JavaScript
"use strict";
|
|
|
|
const webpack = require("../../../");
|
|
const RequestShortener = require("../../../lib/RequestShortener");
|
|
const { compareModulesById } = require("../../../lib/util/comparators");
|
|
|
|
module.exports = {
|
|
mode: "production",
|
|
optimization: { chunkIds: false },
|
|
entry: {
|
|
entry: "./entry"
|
|
},
|
|
plugins: [
|
|
new webpack.ids.NamedChunkIdsPlugin((chunk, { chunkGraph }) => {
|
|
if (chunk.name) {
|
|
return chunk.name;
|
|
}
|
|
const chunkModulesToName = chunk =>
|
|
Array.from(
|
|
chunkGraph.getOrderedChunkModulesIterable(
|
|
chunk,
|
|
compareModulesById(chunkGraph)
|
|
),
|
|
mod => {
|
|
const rs = new RequestShortener(mod.context);
|
|
return rs.shorten(mod.request).replace(/[./\\]/g, "_");
|
|
}
|
|
).join("-");
|
|
|
|
if (chunkGraph.getNumberOfChunkModules(chunk) > 0) {
|
|
return `chunk-containing-${chunkModulesToName(chunk)}`;
|
|
}
|
|
|
|
return null;
|
|
})
|
|
]
|
|
};
|