In my Angular project, I need to use PHP in index.html file. I already renamed it to index.php and updated angular.json to use index.php in index property.
My problem is, after running ng build command, the PHP codes in the generated index.php file in dist directory are commented.
<!--?php
$websiteCode = getenv('SITE_CODE');
?--><!DOCTYPE html><html lang="en"><head>
<meta charset="utf-8">
<title>ClientPortal</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles.31d6cfe0d16ae931b73c.css"></head>
<body>
<!--?=$websiteCode?-->
<app-root></app-root>
<script src="runtime.f3b55109ab97bda870bd.js" defer></script><script src="polyfills.a58f45ef9ccddb12523d.js" defer></script><script src="main.6629fcd1d3960ef0deb9.js" defer></script>
</body></html>
Is there a configuration I need to update or specify so that PHP codes will not be commented? I am using Angular 12. This is working fine in my existing Angular projects using Angular 7.

ng serve(and I thinkng buildwould have the same limitations for the same reasons) to work with PHP. You need to pass those server side data to your angular app in a different way."optimization": {"styles": {"inlineCritical": false}}.