# Removing unused CSS with Purgecss/UnCSS

**URL:** https://discourse.roots.io/t/removing-unused-css-with-purgecss-uncss/11586
**Category:** sage
**Tags:** sage9
**Created:** 2018-02-12T08:53:35Z
**Posts:** 27
**Showing post:** 13 of 27

## Post 13 by @jasonbaciulis — 2018-06-01T05:13:44Z

If anyone else is getting this error with Webpack 3 and purgeCSS:  
`TypeError: Cannot read property 'compilation' of undefined`

Then you need to use purgeCSS version compatible with Webpack 3:  
`yarn add purgecss-webpack-plugin@0.23.0 -D`

**Another tip.**  
`cssnanoConfig` inside `postcss.config.js` is set to remove all comments and that prevents whitelisting directly within SCSS files. So just set to use default preset:

`const cssnanoConfig = { preset: ['default'] };`

Now just mark comments as important `/*! purgecss ignore */` and cssnano will leave them be.

---

_[View the full topic](https://discourse.roots.io/t/removing-unused-css-with-purgecss-uncss/11586)._
