Skip to content

Commit 2326850

Browse files
christianliebelhansl
authored andcommitted
refactor(@angular/pwa): rename manifest.json to manifest.webmanifest
Using the `webmanifest` file extension makes it easier to target the web app manifest in server configs and apply the correct MIME type (see w3c/manifest#689 (comment)).
1 parent 2f262bb commit 2326850

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

packages/angular/pwa/pwa/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function updateIndexFile(path: string): Rule {
7474

7575
rewriter.on('endTag', (endTag: { tagName: string }) => {
7676
if (endTag.tagName === 'head') {
77-
rewriter.emitRaw(' <link rel="manifest" href="manifest.json">\n');
77+
rewriter.emitRaw(' <link rel="manifest" href="manifest.webmanifest">\n');
7878
rewriter.emitRaw(' <meta name="theme-color" content="#1976d2">\n');
7979
} else if (endTag.tagName === 'body' && needsNoScript) {
8080
rewriter.emitRaw(
@@ -156,7 +156,7 @@ export default function (options: PwaOptions): Rule {
156156
}
157157

158158
// Add manifest to asset configuration
159-
const assetEntry = join(normalize(project.root), 'src', 'manifest.json');
159+
const assetEntry = join(normalize(project.root), 'src', 'manifest.webmanifest');
160160
for (const target of [...buildTargets, ...testTargets]) {
161161
if (target.options) {
162162
if (target.options.assets) {

packages/angular/pwa/pwa/index_spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ describe('PWA Schematic', () => {
7171

7272
it('should create a manifest file', (done) => {
7373
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).toPromise().then(tree => {
74-
expect(tree.exists('/projects/bar/src/manifest.json')).toEqual(true);
74+
expect(tree.exists('/projects/bar/src/manifest.webmanifest')).toEqual(true);
7575
done();
7676
}, done.fail);
7777
});
7878

7979
it('should set the name & short_name in the manifest file', (done) => {
8080
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).toPromise().then(tree => {
81-
const manifestText = tree.readContent('/projects/bar/src/manifest.json');
81+
const manifestText = tree.readContent('/projects/bar/src/manifest.webmanifest');
8282
const manifest = JSON.parse(manifestText);
8383

8484
expect(manifest.name).toEqual(defaultOptions.title);
@@ -90,7 +90,7 @@ describe('PWA Schematic', () => {
9090
it('should set the name & short_name in the manifest file when no title provided', (done) => {
9191
const options = {...defaultOptions, title: undefined};
9292
schematicRunner.runSchematicAsync('ng-add', options, appTree).toPromise().then(tree => {
93-
const manifestText = tree.readContent('/projects/bar/src/manifest.json');
93+
const manifestText = tree.readContent('/projects/bar/src/manifest.webmanifest');
9494
const manifest = JSON.parse(manifestText);
9595

9696
expect(manifest.name).toEqual(defaultOptions.project);
@@ -103,7 +103,7 @@ describe('PWA Schematic', () => {
103103
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).toPromise().then(tree => {
104104
const content = tree.readContent('projects/bar/src/index.html');
105105

106-
expect(content).toMatch(/<link rel="manifest" href="manifest.json">/);
106+
expect(content).toMatch(/<link rel="manifest" href="manifest.webmanifest">/);
107107
expect(content).toMatch(/<meta name="theme-color" content="#1976d2">/);
108108
expect(content)
109109
.toMatch(/<noscript>Please enable JavaScript to continue using this application.<\/noscript>/);
@@ -118,7 +118,7 @@ describe('PWA Schematic', () => {
118118
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).toPromise().then(tree => {
119119
const content = tree.readContent('projects/bar/src/index.html');
120120

121-
expect(content).toMatch(/<link rel="manifest" href="manifest.json">/);
121+
expect(content).toMatch(/<link rel="manifest" href="manifest.webmanifest">/);
122122
expect(content).toMatch(/<meta name="theme-color" content="#1976d2">/);
123123
expect(content).not
124124
.toMatch(/<noscript>Please enable JavaScript to continue using this application.<\/noscript>/);
@@ -134,7 +134,7 @@ describe('PWA Schematic', () => {
134134
const targets = config.projects.bar.architect;
135135

136136
['build', 'test'].forEach((target) => {
137-
expect(targets[target].options.assets).toContain('projects/bar/src/manifest.json');
137+
expect(targets[target].options.assets).toContain('projects/bar/src/manifest.webmanifest');
138138
});
139139
done();
140140
}, done.fail);

0 commit comments

Comments
 (0)