We also ran into this issue recently with an update to angular 12.2.7, I was able to unbreak it with the following build setting for production:
in angular.json:configurations
...
"optimization":{
"scripts":false,
"styles":true,
"fonts":true
}
but that leaves the javascript as unminified/obfuscated (not ideal for a prod deployment)
I was able to roll back angular to 12.1.4 and the build started working again with no modifications to the optimization setting (leaving at default)