Setting up CSS bundling in Webpack

The learned method of adding CSS to a page may not be very successful. It is often more convenient to collect all CSS files in a separate bundle with styles.

For this you need the plugin mini-css-extract-plugin. Let's install it:

terminalnpm install mini-css-extract-plugin --save-dev

Let's import it:

webpack.config.jsimport MiniCssExtractPlugin from 'mini-css-extract-plugin';

Let's add to the plugins setting:

webpack.config.jsexport default {
  entry: './src/index.js',
  plugins: [new MiniCssExtractPlugin()],
};

Now let's replace style-loader with the loader from our plugin:

webpack.config.jsexport default {
  entry: './src/index.js',
  plugins: [new MiniCssExtractPlugin()],
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [MiniCssExtractPlugin.loader, 'css-loader'],
      },
    ],
  },
};
Задание 1

Perform the settings described.