Skip to content

Commit 9a1210c

Browse files
Broccohansl
authored andcommitted
fix(@schematics/angular): Transfer baseHref when during update process
fixes #10915
1 parent f2d5bbf commit 9a1210c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

packages/schematics/angular/migrations/update-6/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ function extractProjectsConfig(
403403
index: `${appRoot}/${app.index || defaults.index}`,
404404
main: `${appRoot}/${app.main || defaults.main}`,
405405
tsConfig: `${appRoot}/${app.tsconfig || defaults.tsConfig}`,
406+
...(app.baseHref ? { baseHref: app.baseHref } : {}),
406407
...buildDefaults,
407408
};
408409

packages/schematics/angular/migrations/update-6/index_spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,22 @@ describe('Migration to v6', () => {
557557
});
558558
});
559559

560+
it('should not set baseHref on build & serve targets if not defined', () => {
561+
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
562+
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
563+
const build = getConfig(tree).projects.foo.architect.build;
564+
expect(build.options.baseHref).toBeUndefined();
565+
});
566+
567+
it('should set baseHref on build & serve targets if defined', () => {
568+
const config = {...baseConfig};
569+
config.apps[0].baseHref = '/base/href/';
570+
tree.create(oldConfigPath, JSON.stringify(config, null, 2));
571+
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
572+
const build = getConfig(tree).projects.foo.architect.build;
573+
expect(build.options.baseHref).toEqual('/base/href/');
574+
});
575+
560576
it('should add serviceWorker to production configuration', () => {
561577
baseConfig.apps[0].serviceWorker = true;
562578
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));

0 commit comments

Comments
 (0)