diff --git a/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.spec.ts b/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.spec.ts index 3e3293e51e..1f75d44e43 100644 --- a/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.spec.ts +++ b/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.spec.ts @@ -63,4 +63,19 @@ describe('base href webpack plugin', () => { }); plugin.apply(compiler); }); + + it('should replace href attribute when baseHref is empty', function () { + const plugin = new BaseHrefWebpackPlugin({ baseHref: '' }); + + const compiler = mockCompiler(oneLineTrim` + + + `, (_x: any, htmlPluginData: any) => { + expect(htmlPluginData.html).toEqual(oneLineTrim` + + + `); + }); + plugin.apply(compiler); + }); }); diff --git a/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.ts b/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.ts index 76401d9eae..c7a844926a 100644 --- a/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.ts +++ b/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.ts @@ -7,7 +7,7 @@ export class BaseHrefWebpackPlugin { apply(compiler: any): void { // Ignore if baseHref is not passed - if (!this.options.baseHref) { + if (!this.options.baseHref && this.options.baseHref !== '') { return; }