S
S
Sergey Novikov2020-06-08 10:55:23
webpack
Sergey Novikov, 2020-06-08 10:55:23

Can't write config for webpack 4?

There was a text-extract-plugin when updating webpack to version 4, it stopped working, the documentation says to switch to minicssextractplugin. But I can’t set it up, it says an error that miniCssExtractPlugin is not a function, help me fix it, I need it very urgently.

const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = function (paths) {
  return {
    module: {
      rules: [
        {
          test: /\.scss$/,
          include: paths,
          use: [
            {
              loader: MiniCssExtractPlugin.loader({
                options: {
                  publicPath: "../",
                },
                fallback: "style-loader",
                use: ["css-loader", "sass-loader"],
              }),
            }
          ],
        },
        {
          test: /\.css$/,
          include: paths,
          use: [
            {
              loader: MiniCssExtractPlugin.loader({
                fallback: "style-loader",
                use: "css-loader",
              }),
            },
          ],
        },
      ],
    },
    plugins: [new MiniCssExtractPlugin("./css/[name].css")],
  };
};

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question