# Critical CSS plugin

**URL:** https://discourse.roots.io/t/critical-css-plugin/11855
**Category:** sage
**Tags:** webpack
**Created:** 2018-03-08T14:32:25Z
**Posts:** 31
**Showing post:** 6 of 31

## Post 6 by @chrisrhymes — 2018-03-13T11:18:58Z

So I’ve managed to make some progress using [critical-webpack-plugin](https://github.com/iGitScor/critical-webpack-plugin). I’ve added the following to the webpack.config.optimize.js file to get it to generate a critical css file and then use the above code example to inject critical assets. (Replacing path/to/site with the url to your site).

```
const CriticalWebpackPlugin = require('critical-webpack-plugin');
module.exports = {
plugins: [
new ImageMinPlugin(...),
new CriticalWebpackPlugin({
      src: 'http://path/to/site',
      dest: 'critical.css',
      width: 480,
      height: 800,
      pathPrefix: '/styles',
      minify: true
    }),
]
}
```

---

_[View the full topic](https://discourse.roots.io/t/critical-css-plugin/11855)._
