---
title: "Comment by Dietrich Wallmann on \"Speedy and Stylish - How to style NextJS with Bootstrap 5, SASS, and PurgeCSS\" | Hashnode"
description: "Hi, thanks for your article on how to include sass and bootstrap into a next.js project. As for the caveat, you can evaluate the process.env.NODE_ENV variable a"
url: "https://hashnode.com/posts/style-nextjs-with-bootstrap-5-sass-and-purgecss/60c1f9cb18e6d852c62ee73a/comment/6145d0aca2b54e17a52c235b"
---

[Discussion](https://hashnode.com/posts/style-nextjs-with-bootstrap-5-sass-and-purgecss/60c1f9cb18e6d852c62ee73a)

Comment [Speedy and Stylish - How to style NextJS with Bootstrap 5, SASS, and PurgeCSS](https://hashnode.com/posts/style-nextjs-with-bootstrap-5-sass-and-purgecss/60c1f9cb18e6d852c62ee73a)

[Dietrich Wallmann](https://hashnode.com/@soldi)

[Sep 18, 2021](https://hashnode.com/posts/style-nextjs-with-bootstrap-5-sass-and-purgecss/60c1f9cb18e6d852c62ee73a/comment/6145d0aca2b54e17a52c235b)

Hi, thanks for your article on how to include sass and bootstrap into a next.js project. As for the caveat, you can evaluate the _process.env.NODE\_ENV_ variable and add the purgecss setting block only in the production environment. For more, see the next.js docs: [Customizing Plugins](https://nextjs.org/docs/advanced-features/customizing-postcss-config#customizing-plugins) . Here is my postcss.config.js file:

```
module.exports = {
  plugins: [
    'postcss-flexbugs-fixes',
    [
      'postcss-preset-env',
      {
        autoprefixer: {flexbox: 'no-2009'},
        stage: 3,
        features: {'custom-properties': false},
      },
    ],
  ],
};

if (process.env.NODE_ENV === 'production') {
  module.exports.plugins.push([
    '@fullhuman/postcss-purgecss',
    {
      content: ['./src/**/*.{js,jsx,ts,tsx}', './pages/**/*.{js,jsx,ts,tsx}'],
      defaultExtractor: (content) => content.match(/[\w-/:]+(?<!:)/g) || [],
      safelist: ['html', 'body'],
    },
  ]);
}
```

In my still empty project that includes bootstrap, I could decrease the size of the .next folder from 6.6 MB to 5.2MB using purgecss in the production build.
