Skip to content

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

@PrinceGupta1999

Description

@PrinceGupta1999

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions