Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fa0a06f

Browse filesBrowse files
committed
fix(@angular/pwa): support using default index option when not present
The `@angular/pwa` add schematic now attempts to discover a default index option value if a configuration usage path within the build target is possible. The default value as per the `application` build system is `<project_source_root>/index.html`. (cherry picked from commit 8129483)
1 parent 901ab60 commit fa0a06f
Copy full SHA for fa0a06f

File tree

Expand file treeCollapse file tree

1 file changed

+13
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-0
lines changed

‎packages/angular/pwa/pwa/index.ts

Copy file name to clipboardExpand all lines: packages/angular/pwa/pwa/index.ts
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,12 @@ export default function (options: PwaOptions): Rule {
110110

111111
// Find all index.html files in build targets
112112
const indexFiles = new Set<string>();
113+
let checkForDefaultIndex = false;
113114
for (const target of buildTargets) {
114115
if (typeof target.options?.index === 'string') {
115116
indexFiles.add(target.options.index);
117+
} else if (target.options?.index === undefined) {
118+
checkForDefaultIndex = true;
116119
}
117120

118121
if (!target.configurations) {
@@ -122,13 +125,23 @@ export default function (options: PwaOptions): Rule {
122125
for (const options of Object.values(target.configurations)) {
123126
if (typeof options?.index === 'string') {
124127
indexFiles.add(options.index);
128+
} else if (options?.index === undefined) {
129+
checkForDefaultIndex = true;
125130
}
126131
}
127132
}
128133

129134
// Setup sources for the assets files to add to the project
130135
const sourcePath = project.sourceRoot ?? posix.join(project.root, 'src');
131136

137+
// Check for a default index file if a configuration path allows for a default usage
138+
if (checkForDefaultIndex) {
139+
const defaultIndexFile = posix.join(sourcePath, 'index.html');
140+
if (host.exists(defaultIndexFile)) {
141+
indexFiles.add(defaultIndexFile);
142+
}
143+
}
144+
132145
// Setup service worker schematic options
133146
const { title, ...swOptions } = options;
134147

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.