You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the CLI supports custom PostCSS configurations in the format of JSON files. The problem is that the JSON format has its limitation. In our case for example we try to configure CSS purging with the fullhuman/postcss-purgecss plugin.
Unfortunately this config is not enough and therefore we would need to configure some extractors:
importpurgeJsfrom"purgecss-from-js";importpurgeHtmlfrom"purgecss-from-html";constoptions={content: [],// files to extract the selectors fromcss: [],// cssextractors: [{extractor: purgeJs,extensions: ["js"],},{extractor: purgeHtml,extensions: ["html"],},],};exportdefaultoptions;
Describe the solution you'd like
Support PostCSS configuration files writen in JavaScript.
Describe alternatives you've considered
No response
Reacted by Tomas Trajan, Saul Moro, Alaa El-Din Ahmed, Arif Tunahan Deniz, Vijay, hyperlife1119, Kai Röder, Marco Rinaldi, Enea Jahollari, Ahn and 24 more
Reacted by Alaa El-Din Ahmed, hyperlife1119, Ahn, Cristian Deschamps, Tyler Dunn, noguespi, Leblanc Meneses and Yuriy Grunin
This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.
You can find more details about the feature request process in our documentation.
@kreuzerk I had a similar requirement and created my own PostCSS plugin as a workaround. You can import @fullhuman/postcss-purgecss in your plugin and pass the necessary configuration to it.
This is an example plugin:
// custom-postcss-plugin.jsconstpostcss=require('postcss');constrtlcss=require('postcss-rtlcss');module.exports=(opts={})=>{return{postcssPlugin: 'esbuild-postcss-rtlcss',Once(...args){constoptions=// my optionsrtlcss(options).Once(...args);}};};module.exports.postcss=true;
After that, you need to move this plugin to node_modules. Adding it to the package.json as a package is the easiest way to do it.
I've been looking for a long time to custom postcss config, then i found your issue, it helps...
official doc did not mention how to config postcss lol
@zcmk123 same issue here, did you find the official way to config postcss in angular cli ?
I'm currently exploring a library called primeflex, which uses the same approach for css as Tailwinds. Builds are bloated and definitely, some cleanup is needed, but I'm not able to find a solid source of information, all I've found so far are workarounds.
@zcmk123 same issue here, did you find the official way to config postcss in angular cli ? I'm currently exploring a library called primeflex, which uses the same approach for css as Tailwinds. Builds are bloated and definitely, some cleanup is needed, but I'm not able to find a solid source of information, all I've found so far are workarounds.
You can just make a js file in the same directory as the postcss.config.json, e.g. my-plugin.js, which might contain like
constfooPlugin=require('foo-plugin');module.exports=(opts={})=>{// touch up optsreturnfooPlugin(opts);};module.exports.postcss=true
{
"plugins": {
"./my-plugin": {}
}
}
and then you don't have to mess around with devDependencies, and at least in my case, the custom plugin logic is simpler. (I needed to pass js functions in the options...)
Activity
angular-robot commentedon Jun 12, 2024
This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.
You can find more details about the feature request process in our documentation.
mehmet-erim commentedon Jun 26, 2024
@kreuzerk I had a similar requirement and created my own PostCSS plugin as a workaround. You can import @fullhuman/postcss-purgecss in your plugin and pass the necessary configuration to it.
This is an example plugin:
After that, you need to move this plugin to node_modules. Adding it to the package.json as a package is the easiest way to do it.
And define your plugin as follows:
postcss.config.json
{ "plugins": { "tailwindcss": { "config": "tailwind.config.js" }, "autoprefixer": {}, "my-custom-postcss-plugin": {} } }nivekcode commentedon Jun 26, 2024
Nice. Thx @mehmet-erim for sharing, will give it a try.
angular-robot commentedon Jul 22, 2024
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
zcmk123 commentedon Aug 1, 2024
I've been looking for a long time to custom postcss config, then i found your issue, it helps...
official doc did not mention how to config postcss lol
robmanganelly commentedon Aug 17, 2024
@zcmk123 same issue here, did you find the official way to config postcss in angular cli ?
I'm currently exploring a library called primeflex, which uses the same approach for css as Tailwinds. Builds are bloated and definitely, some cleanup is needed, but I'm not able to find a solid source of information, all I've found so far are workarounds.
zcmk123 commentedon Aug 19, 2024
@robmanganelly i believe there isn't an official way to config postcss, at least in angular official docs. angular cli support tailwindcss and i've check their source code, angular cli load postcss config for sure, but only in json format.
https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/utils/postcss-configuration.ts#L20
https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/utils/postcss-configuration.ts#L77
currently in my project, i created a postcss.config.json to customize postcss
stefankoserkov commentedon Mar 26, 2025
Any updates on this enhancement? it would be very useful.
7iomka commentedon May 25, 2026
The worst postcss config support ever in frontend community :(
imirkin commentedon Sep 25, 2026
A slight improvement, IMO, on @mehmet-erim's comment #27819 (comment):
You can just make a js file in the same directory as the
postcss.config.json, e.g.my-plugin.js, which might contain like{ "plugins": { "./my-plugin": {} } }and then you don't have to mess around with
devDependencies, and at least in my case, the custom plugin logic is simpler. (I needed to pass js functions in the options...)