I have an Angular project created with Angular CLI, so I have angular.json file for configuring the build.
I wanted to integrate PurgeCSS as it seems to be a great tool
You can simply run the following commands in your project root directory
npm i -D postcss-import postcss-loader postcss-scss
ng add ngx-build-plus
In angular.json, make the following replacements in "architect"
section:
"builder": "@angular-devkit/build-angular:browser"
with "builder": "ngx-build-plus:browser"
under "build"
,
"builder": "@angular-devkit/build-angular:dev-server"
with "builder": "ngx-build-plus:dev-server"
under "serve"
,
"builder": "@angular-devkit/build-angular:karma"
with "builder": "ngx-build-plus:karma"
under "test"
,
You should also add "extraWebpackConfig": "webpack.config.js"
under options in the respected sections.