Add support for configuring PostCSS for Angular projects
See original GitHub issueI created new nx/angular project with tailwind and storybook. All works fine, but now I need to add postcss nesting plugin, like postcss-nested
or tailwindcss/nesting
.
I created postcss.config.js
in my app and lib directory with following config
module.exports = {
plugins: [
'postcss-import',
'tailwindcss/nesting',
'tailwindcss',
'autoprefixer',
]
}
Current Behavior
I got “Nested CSS was detected, but CSS nesting has not been configured correctly. Please enable a CSS nesting plugin before Tailwind in your configuration.” message in build log. Seems like nx doesn’t respect postcss.config.js.
Expected Behavior
Should be possibe to add postcss-plugins.
Environment
Node : 16.13.0
OS : win32 x64
yarn : 1.22.17
nx : 13.8.3
@nrwl/angular : 13.8.3
@nrwl/cli : 13.8.3
@nrwl/cypress : 13.8.3
@nrwl/detox : undefined
@angular/cli: 13.2.5
@angular/compiler-cli: 13.2.4
@angular/language-service: 13.2.4
@storybook/angular: 6.4.19
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Anyone had any luck adding a Post CSS plugin to an Angular ...
Just adding postcss to package.json and having this config file works fine for me. What version are you working with? module.exports = {...
Read more >Postcss plugins in Angular/cli v11.2 - Stack Overflow
I need to postcss my css with plugin postcss-preset-env for IE11 compatibility (don't ask).
Read more >PostCSS - a tool for transforming CSS with JavaScript
Transform CSS with the power of JavaScript. Auto-prefixing, future CSS syntaxes, modules, linting and more are possible with hundreds of PostCSS plugins.
Read more >Compiling SASS and PostCSS with Angular CLI | Codementor
This tutorial will help you configure the build to compile global CSS as well as allow you to use SASS variables declared globally...
Read more >The [New] State of CSS in Angular | by Emma Twersky
Angular v11.2 added native support for running TailwindCSS ... Create a TailwindCSS configuration file in the workspace or project root
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, i tried, but it looks like
postcss.config.js
just ignored by builder.@zvnt you need to be careful not to overwrite the default Angular CLI webpack configuration for styles. The above will replace the rule configuration for the
.css
extension. Instead, you could use the function syntax that receives the base webpack configuration and update it with the changes you need:That way, you can obtain the specific rule(s) you want to update from the base configuration and make the needed changes without losing any functionality. You can take a look at some docs/examples updating the webpack config in a similar way to get an idea:
https://indepth.dev/posts/1294/angular-css-modules https://github.com/angular/angular-cli/issues/8427#issuecomment-751520349