-
Notifications
You must be signed in to change notification settings - Fork 11.9k
feat(@angular-devkit/build-angular): support using custom postcss configuration with application builder #27000
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
feat(@angular-devkit/build-angular): support using custom postcss configuration with application builder #27000
Conversation
9c553ef to
6f40435
Compare
…figuration with application builder
When using the `application` builder, the usage of a custom postcss configuration is now supported.
The builder will automatically detect and use specific postcss configuration files if present in
either the project root directory or the workspace root. Files present in the project root will have
priority over a workspace root file. If using a custom postcss configuration file, the automatic
tailwind integration will be disabled. To use both a custom postcss configuration and tailwind, the
tailwind setup must be included in the custom postcss configuration file.
The configuration files must be JSON and named one of the following:
* `postcss.config.json`
* `.postcssrc.json`
A configuration file can use either an array form or an object form to setup plugins.
An example of the array form:
```
{
"plugins": [
"tailwindcss",
["rtlcss", { "useCalc": true }]
]
}
```
The same in an object form:
```
{
"plugins": {
"tailwindcss": {},
"rtlcss": { "useCalc": true }
}
}
```
NOTE: Using a custom postcss configuration may result in reduced build and rebuild
performance. Postcss will be used to process all global and component stylesheets
when a custom configuration is present. Without a custom postcss configuration,
postcss is only used for a stylesheet when tailwind is enabled and the stylesheet
requires tailwind processing.
6f40435 to
593f8cc
Compare
| this.postcssProcessor = postcssProcessor.get(postCssInstanceKey)?.deref(); | ||
|
|
||
| if (!this.postcssProcessor) { | ||
| postcss ??= (await import('postcss')).default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the topic of overhead. I always liked that you moved sass into a worker. So you already made the heavy lifting of worker handling and sending options, source and sourceMaps back and forth. Instead you could have the StylesheetPluginFactory itself as a worker, so the the entire stylesheet pipeline.
We did that in our custom build and it cut buildtime in half. But we do tons of postcss (purge, nano, autoprefix, url replacement), so I'm not sure about the average cli user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind this though, I love that you add postcss support :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improvements to stylesheet processing performance are definitely something we are considering. There is added complexity with some of the options though. Based on usage, we will evaluate potentials such as the parallel processing you mentioned.
However, when using CSS directly there is currently a fast path that keeps all processing inside the bundler when tailwind is not used. So even with something like the worker integration there would still be some performance overhead.
Also, the application builder uses the bundler (esbuild) to handle CSS minification and prefixing so you may be able to remove those from your stylesheet pipeline if your application is on the new builder.
|
Update for those stuck into integrating rtlcss to angular you can make the components auto flip like this, make sure to use This seem to work as all what we need to make mention #26867 |
|
I am really going crazy but is this really everything that needs to be done? Create I was able to generate rtl styles with the help of postcss-cli and commands, so all should be installed correctly. And also, I guess a little bit offtopic, can |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |

When using the
applicationbuilder, the usage of a custom postcss configuration is now supported. The builder will automatically detect and use specific postcss configuration files if present in either the project root directory or the workspace root. Files present in the project root will have priority over a workspace root file. If using a custom postcss configuration file, the automatic tailwind integration will be disabled. To use both a custom postcss configuration and tailwind, the tailwind setup must be included in the custom postcss configuration file.The configuration files must be JSON and named one of the following:
postcss.config.json.postcssrc.jsonA configuration file can use either an array form or an object form to setup plugins. An example of the array form:
The same in an object form:
NOTE: Using a custom postcss configuration may result in reduced build and rebuild
performance. Postcss will be used to process all global and component stylesheets
when a custom configuration is present. Without a custom postcss configuration,
postcss is only used for a stylesheet when tailwind is enabled and the stylesheet
requires tailwind processing.
Closes #25411
Closes #26867