@@ -16,6 +16,7 @@ import { createResultDir, addDirectory, addFile } from '../utils/resultHelper';
1616import { createModuleBuilder } from './ModuleBuilder' ;
1717import { ProjectPreProcessor , ProjectPostProcessor , IContextData } from '../types/core' ;
1818import { CodeGeneratorError } from '../types/error' ;
19+ import { isBuiltinSlotName } from '../const' ;
1920
2021interface IModuleInfo {
2122 moduleName ?: string ;
@@ -272,17 +273,8 @@ export class ProjectBuilder implements IProjectBuilder {
272273 } ) ;
273274 }
274275
275- // TODO: 更多 slots 的处理??是不是可以考虑把 template 中所有的 slots 都处理下?
276- // const whitelistSlotNames = [
277- // 'router',
278- // 'entry',
279- // 'appConfig',
280- // 'buildConfig',
281- // 'router',
282- // ];
283- // Object.keys(this.template.slots).forEach((slotName: string) => {
284-
285- // });
276+ // handle extra slots
277+ await this . generateExtraSlots ( builders , parseResult , buildResult ) ;
286278
287279 // Post Process
288280 const isSingleComponent = parseResult ?. project ?. projectRemark ?. isSingleComponent ;
@@ -339,6 +331,22 @@ export class ProjectBuilder implements IProjectBuilder {
339331
340332 return builders ;
341333 }
334+
335+ private async generateExtraSlots (
336+ builders : Record < string , IModuleBuilder > ,
337+ parseResult : IParseResult ,
338+ buildResult : IModuleInfo [ ] ,
339+ ) {
340+ for ( const slotName in this . template . slots ) {
341+ if ( ! isBuiltinSlotName ( slotName ) ) {
342+ const { files } = await builders [ slotName ] . generateModule ( parseResult ) ;
343+ buildResult . push ( {
344+ path : this . template . slots [ slotName ] . path ,
345+ files,
346+ } ) ;
347+ }
348+ }
349+ }
342350}
343351
344352export function createProjectBuilder ( initOptions : ProjectBuilderInitOptions ) : IProjectBuilder {
0 commit comments