This resolves https://github.com/angular/angular-cli/issues/10333 and nicely cleans up the code. PR Close #23234