(project: ProjectDefinition)
| 15 | * This only searches the base options for each target and not any defined target configurations. |
| 16 | */ |
| 17 | export function getProjectIndexFiles(project: ProjectDefinition): string[] { |
| 18 | // Use a Set to remove duplicate index files referenced in multiple build targets of a project. |
| 19 | const paths = new Set<string>(); |
| 20 | |
| 21 | for (const target of getProjectBuildTargets(project)) { |
| 22 | const indexValue = target.options?.['index']; |
| 23 | |
| 24 | switch (typeof indexValue) { |
| 25 | case 'string': |
| 26 | // "index": "src/index.html" |
| 27 | paths.add(indexValue); |
| 28 | break; |
| 29 | case 'object': |
| 30 | // "index": { "input": "src/index.html", ... } |
| 31 | if (indexValue && 'input' in indexValue) { |
| 32 | paths.add(indexValue['input'] as string); |
| 33 | } |
| 34 | break; |
| 35 | case 'undefined': |
| 36 | // v20+ supports an optional index field; default of `<project_source_root>/index.html` |
| 37 | // `project_source_root` is the project level `sourceRoot`; default of `<project_root>/src` |
| 38 | paths.add(join(project.sourceRoot ?? join(project.root, 'src'), 'index.html')); |
| 39 | break; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | return Array.from(paths); |
| 44 | } |
no test coverage detected