2017-03-26 15:41:52 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const NamedChunksPlugin = require("../../../lib/NamedChunksPlugin");
|
|
|
|
const RequestShortener = require("../../../lib/RequestShortener");
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: {
|
|
|
|
"entry": "./entry",
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new NamedChunksPlugin(function(chunk) {
|
|
|
|
if(chunk.name) {
|
|
|
|
return chunk.name;
|
|
|
|
}
|
2017-04-21 16:05:56 +08:00
|
|
|
const chunkModulesToName = (chunk) => chunk.mapModules((mod) => {
|
2017-03-26 15:41:52 +08:00
|
|
|
const rs = new RequestShortener(mod.context);
|
|
|
|
return rs.shorten(mod.request).replace(/[.\/\\]/g, "_");
|
|
|
|
}).join("-");
|
|
|
|
|
2017-04-21 16:05:56 +08:00
|
|
|
if(chunk.getNumberOfModules() > 0) {
|
|
|
|
return `chunk-containing-${chunkModulesToName(chunk)}`;
|
2017-03-26 15:41:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
};
|