Angular build process is commenting out PHP tags

Viewed 68

I asking my first Angular-related question. Please bear with me if it has already been answered. Hopefully, you know the answer and have time to share it.

My current use case is the following:

  1. After building the Angular app, the default page must be index.php (I have that currently working)
  2. The index.php file contains a PHP logic which is required for various things. For the sake of simplicity, let's assume that the PHP logic needs to inject a special dynamic metatag in the HTML . Values for that metatag are inherited from a parent non-Angular app (a plain old-fashioned CMS).
  3. I am using the latest Angular version.

My current issue:

Whenever I run ng build, PHP tags in my index.php file get converted from <?php ... ?> to <--?php ... ?-->.

Questions

  1. Why is this happening?
  2. Is there any way to configure this behaviour?

Many thanks in advance. I appreciate any answers.

1 Answers

According to anycodings.com, a CSS optimizer causes that potential bug. The solution is to disable inlineCritical like this:

Add this option in angular.json, in each build/configuration :

"optimization": {
            "styles": {
              "inlineCritical": false
            }
          }
Related