简体   繁体   中英

Angular build process is commenting out PHP tags

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.

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 } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM