Skip to content

Commit

Permalink
refactor(@angular/pwa): rename manifest.json to manifest.webmanifest
Browse files Browse the repository at this point in the history
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)).
  • Loading branch information
christianliebel committed Nov 9, 2018
1 parent 4059fe8 commit 2060c89
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/angular/pwa/pwa/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function updateIndexFile(path: string): Rule {

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

// Add manifest to asset configuration
const assetEntry = join(normalize(project.root), 'src', 'manifest.json');
const assetEntry = join(normalize(project.root), 'src', 'manifest.webmanifest');
for (const target of [...buildTargets, ...testTargets]) {
if (target.options) {
if (target.options.assets) {
Expand Down
12 changes: 6 additions & 6 deletions packages/angular/pwa/pwa/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ describe('PWA Schematic', () => {

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

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

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

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

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

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

['build', 'test'].forEach((target) => {
expect(targets[target].options.assets).toContain('projects/bar/src/manifest.json');
expect(targets[target].options.assets).toContain('projects/bar/src/manifest.webmanifest');
});
done();
}, done.fail);
Expand Down

0 comments on commit 2060c89

Please sign in to comment.