Skip to content

feat(@angular-devkit/build-angular): add option to retain CSS special comments in global styles #26444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Nov 21, 2023

Prior to this change special CSS comments /*! comment */ were being removed during minification when using the application builder. This caused tools that ran post build that rely on such comments such as purgeCSS and critters not to function properly.

We now provide a removeSpecialComments option to enable retention of these comments in global CSS files.

Usage example:

{
  "projects": {
    "my-app": {
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:application",
          "configurations": {
            "production": {
              "optimization": {
                "styles": {
                  "removeSpecialComments": false
                }
              }
            }
          }
        }
      }
    }
  }
}

Closes: #26432

@alan-agius4 alan-agius4 requested a review from clydin November 21, 2023 08:29
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Nov 21, 2023
@CarlosTorrecillas
Copy link
Contributor

Thanks @alan-agius4, as always, providing an outstanding turnaround !

@alan-agius4 alan-agius4 added needs: discussion On the agenda for team meeting to determine next steps and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 21, 2023
@CarlosTorrecillas
Copy link
Contributor

Hi guys, just for our information, is this planned to be merged at some point soon? No rush at all, it is because this is holding us back from release the upgrade to Angular 17. Thanks!

@alan-agius4 alan-agius4 changed the title fix(@angular-devkit/build-angular): retain CSS special comments in global styles feta(@angular-devkit/build-angular): add option to retain CSS special comments in global styles Nov 29, 2023
@alan-agius4 alan-agius4 force-pushed the css-retain-special-comments branch 3 times, most recently from 4de7d4c to b945a57 Compare November 29, 2023 10:35
@alan-agius4
Copy link
Collaborator Author

Had a chat with @clydin earlier last week and we decided to go with an additional option. The PR has been updated to add this option.

This should be available as part of 17.1.0.

@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release and removed needs: discussion On the agenda for team meeting to determine next steps target: patch This PR is targeted for the next patch release action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 29, 2023
@alan-agius4 alan-agius4 changed the title feta(@angular-devkit/build-angular): add option to retain CSS special comments in global styles feat(@angular-devkit/build-angular): add option to retain CSS special comments in global styles Nov 29, 2023
@alan-agius4 alan-agius4 force-pushed the css-retain-special-comments branch from b945a57 to 5084dbe Compare November 29, 2023 10:37
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Nov 29, 2023
… comments in global styles

Prior to this change special CSS comments `/*! comment */` were being removed during minification when using the application builder. This caused tools that ran post build that rely on such comments such as purgeCSS and critters not to function properly.

We now provide a `removeSpecialComments` option to enable retention of these comments in global CSS files.

Usage example:
```json
{
  "projects": {
    "my-app": {
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:application",
          "configurations": {
            "production": {
              "optimization": {
                "styles": {
                  "removeSpecialComments": false
                }
              }
            }
          }
        }
      }
    }
  }
}
```

Closes: angular#26432
@alan-agius4 alan-agius4 force-pushed the css-retain-special-comments branch from 5084dbe to c8578a1 Compare November 29, 2023 16:25
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 29, 2023
@alan-agius4 alan-agius4 merged commit e0b274b into angular:main Nov 29, 2023
@alan-agius4 alan-agius4 deleted the css-retain-special-comments branch November 29, 2023 16:32
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Special comments /*! are removed from the styles.css
3 participants