Skip to content
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

Add postcss-preset-env to Angular build process / allow for configuring custom PostCSS plugins #26536

Closed
PrinceGupta1999 opened this issue Nov 30, 2023 · 2 comments

Comments

@PrinceGupta1999
Copy link

PrinceGupta1999 commented Nov 30, 2023

Command

build, serve

Description

The Angular docs mention The Angular CLI uses Browserslist to ensure compatibility with different browser versions. And while this story works great in the Javascript side, the CSS story is not as good.

Currently for processing CSS PostCSS is used during the build process, and the only plugin used for increasing browser compatibility is the use of the autoprefixer plugin.

That would be fine if the build process allowed configuration of the postcss plugins being used but not allowing that severely limits the extent of browser support which could have been otherwise extended using plugins like postcss-preset-env. For example, in our use case we are required to support Chrome version 80 but since more and more UI libraries like PrimeNg are moving towards use of @layer which is not supported by earlier browsers it is proving impossible for us to upgrade to use newer versions of these UI libraries.

Describe the solution you'd like

Similar to the configuration being done for Tailwind it could be possible to add support for loading postCss configuration from the standard postcss.config.js file.

There may also be need to either merge / override the default configuration in case the postcss config is provided.

Describe alternatives you've considered

The only alternate that seemed to work for us at the moment was to switch to angular-builders/custom-webpack for building / serving the application and loading the postcss.config.js file using the postcss-loader in webpack.

However the drawback of that was that we could no longer take advantage of the faster Vite / ESBuild speeds that the Angular v17 provides by default.

@alan-agius4
Copy link
Collaborator

Hi @PrinceGupta1999,

Appreciate your feature request, but enabling postcss configuration isn't in our plans currently. At this stage, postcss is utilized solely within Angular CLI for tailwind CSS, as this forces a slower path for stylesheet compilations.

Regarding, adding a postcss plugin in this case will not yield the desired outcome. As the application build pipeline doesn't transform CSS within components present in libraries. Instead, components CSS in libraries is processed based on their configured minimum browser support version before publishing to NPM.

It's important to note that the esbuild-based pipeline does handle the transformation of various CSS syntaxes, such as nesting, among others without the need of postcss.

Angular only officially supports the latest 2 major versions of Chrome currently being 118 and 119. See https://angular.io/guide/browser-support for more information about supported browsers.

See: #8427 (comment) and #8427 for more context about why we do not support custom postcss plugins.

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
@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 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants