Apparently it is not enough to run ng build as the documentation states. It needs to be ng build --configuration=production
ng build
ng build --configuration=production