title: [PURGECSS]: Webpack 5 + VueJS + CSS modules stripping all classes from CSS bundle using PURGECSS
body: <p>When using CSS modules with VueJS and Webpack 5, all classes are removed from the CSS bundle.</p>
  <p>In the options for css-loader, if I have modules: true the CSS bundle is totally empty.</p>
  <p>If I comment that out, the CSS bundle is as expected with all unused classes removed, however the JS bundle no longer has the CSS classes on the component elements.</p>
  <p>If I add the SCSS files to the entry and do not use CSS modules, the CSS bundle is correct as well.</p>
  <p>The issue appears to be when combining modules: true and purgecss.</p>
  <p>Version:</p>
  <p><code>&quot;webpack&quot;: &quot;^5.26.1&quot;</code></p>
  <p><code>&quot;postcss-loader&quot;: &quot;^5.2.0&quot;</code></p>
  <p><code>&quot;postcss-preset-env&quot;: &quot;^6.7.1&quot;</code></p>
  <p>Here is my Webpack config:</p>
  <pre><code>const { merge } = require('webpack-merge');
  const commonConfig = require('./webpack.common.config');
  const MiniCSSExtractPlugin = require('mini-css-extract-plugin');
  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  const path = require('path')
  const glob = require(&quot;glob&quot;);
  
  const prodConfig = {
    mode: 'production',
    module: {
      rules: [
        {
          test: /\.scss$/,
          use: [
            {
              loader: MiniCSSExtractPlugin.loader,
            },
            {
              loader: 'css-loader',
              options: { modules: true },
            },
            {
              loader: &quot;postcss-loader&quot;,
                options: {
                  postcssOptions: {
                    plugins: [
                      &quot;postcss-flexbugs-fixes&quot;,
                      &quot;autoprefixer&quot;,
                      &quot;postcss-preset-env&quot;,
                      [
                        &quot;@fullhuman/postcss-purgecss&quot;,
                        {
                          content: [
                            path.join(__dirname, &quot;./public/index.html&quot;),
                            ...glob.sync(
                              `${path.join(__dirname, &quot;src&quot;)}/**/*.vue`,
                              {
                                nodir: true,
                              }
                            ),
                          ],
                        },
                      ],
                    ],
                  },
                }
            },
            'sass-loader',
          ],
        },
        {
          test: /\.css$/,
          use: [
            'vue-style-loader',
            'css-loader',
            'postcss-loader',
            'sass-loader',
          ],
        },
      ],
    },
    plugins: [
      new MiniCSSExtractPlugin({
        filename: 'style.[fullhash].css',
      }),
    ],
  };
  
  if (process.env.BUNDLE_ANALYZER) {
    prodConfig.plugins.push(new BundleAnalyzerPlugin())
  }
  
  module.exports = merge(commonConfig, prodConfig);
  </code></pre>