Mini-css-extract-plugin: I get three css bundles instead of one

Created on 29 Mar 2018  ·  4Comments  ·  Source: webpack-contrib/mini-css-extract-plugin

I tried to extract all css into a single file, using your example.
But I end up with three css files.

Could someone take a short look, to see what is wrong.

Here is a little repo.

Plugins:

new MiniCssExtractPlugin({
        // Options similar to the same options in webpackOptions.output
        // both options are optional
        filename: "[name].css",
        // chunkFilename: "bundle.css"
      })

and:

optimization: {
      minimize: true,
      runtimeChunk: false,
      splitChunks: {
        cacheGroups: {
          styles: {
            name: 'bundle',
            test: /\.css$/,
            chunks: 'all',
            enforce: true
          },
          vendor: {
            chunks: 'initial',
            name: 'vendor',
            priority: -10,
            test: /node_modules/
            // test: /node_modules\/(.*)\.js/
          }
        }
      }
    }
docs

Most helpful comment

As you're using scss files too:

          styles: {
            name: 'bundle',
            test: /\.(css|scss)$/,
            chunks: 'all',
            enforce: true
          },

All 4 comments

@Legends can you provide full config, maybe you have multiple entry point

As you're using scss files too:

          styles: {
            name: 'bundle',
            test: /\.(css|scss)$/,
            chunks: 'all',
            enforce: true
          },

Let's add this to documentation :+1:

Manchmal sieht man den Wald vor lauter Bäumen nicht...
Thanks Sokra!

Was this page helpful?
0 / 5 - 0 ratings