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

Sign up
Appearance settings

Commit b8c50c1

Browse files
alxhubBrocco
authored andcommitted
fix(@angular/cli): check for existing SW manifest should look in project dir
A previous change broke the logic which brings an application ngsw-manifest.json into the Webpack build for merging with the auto-generated configuration. It caused the GlobCopyWebpackPlugin to look in the wrong directory for the existing manifest. This change sets the working directory for the copy plugin explicitly. Fixes #6654.
1 parent ba973d4 commit b8c50c1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

‎packages/@angular/cli/models/webpack-configs/production.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ export const getProdConfig = function (wco: WebpackConfigOptions) {
5757
}
5858

5959
extraPlugins.push(new GlobCopyWebpackPlugin({
60-
patterns: ['ngsw-manifest.json', 'src/ngsw-manifest.json'],
60+
patterns: [
61+
'ngsw-manifest.json',
62+
{glob: 'ngsw-manifest.json', input: path.resolve(projectRoot, appConfig.root), output: ''}
63+
],
6164
globOptions: {
65+
cwd: projectRoot,
6266
optional: true,
6367
},
6468
}));

‎tests/e2e/tests/build/service-worker.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {join} from 'path';
22
import {getGlobalVariable} from '../../utils/env';
3-
import {expectFileToExist, expectFileToMatch} from '../../utils/fs';
3+
import {expectFileToExist, expectFileToMatch,writeFile,moveFile} from '../../utils/fs';
44
import {ng, npm} from '../../utils/process';
55

66
export default function() {
@@ -9,6 +9,8 @@ export default function() {
99
return Promise.resolve();
1010
}
1111

12+
const rootManifest = join(process.cwd(), 'ngsw-manifest.json');
13+
1214
// Can't use the `ng` helper because somewhere the environment gets
1315
// stuck to the first build done
1416
return npm('install', '@angular/service-worker')
@@ -18,5 +20,11 @@ export default function() {
1820
.then(() => expectFileToExist(join(process.cwd(), 'dist/ngsw-manifest.json')))
1921
.then(() => ng('build', '--prod', '--base-href=/foo/bar'))
2022
.then(() => expectFileToExist(join(process.cwd(), 'dist/ngsw-manifest.json')))
21-
.then(() => expectFileToMatch('dist/ngsw-manifest.json', /"\/foo\/bar\/index.html"/));
23+
.then(() => expectFileToMatch('dist/ngsw-manifest.json', /"\/foo\/bar\/index.html"/))
24+
.then(() => writeFile(rootManifest, '{"local": true}'))
25+
.then(() => ng('build', '--prod'))
26+
.then(() => expectFileToMatch('dist/ngsw-manifest.json', /\"local\"/))
27+
.then(() => moveFile(rootManifest, join(process.cwd(), 'src/ngsw-manifest.json')))
28+
.then(() => ng('build', '--prod'))
29+
.then(() => expectFileToMatch('dist/ngsw-manifest.json', /\"local\"/));
2230
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /