chore(v2): better chunk naming

This commit is contained in:
endiliey 2019-05-08 16:54:48 +08:00
parent 174ad279a6
commit 6f011d8e7a

View file

@ -72,7 +72,7 @@ async function loadRoutes(pluginsRouteConfigs) {
const componentChunk = genImportChunk(componentPath, 'component'); const componentChunk = genImportChunk(componentPath, 'component');
addRoutesChunkNames(routePath, 'component', componentChunk); addRoutesChunkNames(routePath, 'component', componentChunk);
function genRouteChunkNames(value) { function genRouteChunkNames(value, prefix) {
if (Array.isArray(value)) { if (Array.isArray(value)) {
return value.map(genRouteChunkNames); return value.map(genRouteChunkNames);
} }
@ -80,14 +80,14 @@ async function loadRoutes(pluginsRouteConfigs) {
if (_.isObject(value) && !value.__import) { if (_.isObject(value) && !value.__import) {
const newValue = {}; const newValue = {};
Object.keys(value).forEach(key => { Object.keys(value).forEach(key => {
newValue[key] = genRouteChunkNames(value[key]); newValue[key] = genRouteChunkNames(value[key], key);
}); });
return newValue; return newValue;
} }
const importChunk = genImportChunk( const importChunk = genImportChunk(
getModulePath(value), getModulePath(value),
'module', prefix,
routePath, routePath,
); );
registry[importChunk.chunkName] = { registry[importChunk.chunkName] = {