How to add a loader to a specific entry in webpack 5?

26 Views Asked by At

I need to add a prefix to a legacy entry. I tried layer and it didn't work. I tried create a custom plugin but it didn't work.

config = {
   entry : {
    main: "./home",
    legacy: "./legacy",
  },

 module: {
    rules: [
      {
        test: /\.(scss|css)$/i,
        use: [
          MiniCssExtractPlugin.loader,
          "css-loader",
          "resolve-url-loader",
          {
            loader: "sass-loader",
            options: {
              sourceMap: true,
              sassOptions: { outputStyle: "expanded" },
            },
          },
          {
            loader: "postcss-loader",
            options: {
              postcssOptions: {
                ident: "postcss-scss",
                syntax: "postcss-scss",
                plugins: [
                       require("postcss-prefixer")({
                        prefix: "legacy-",
                      });
                ],
              },
            },
          },
        ],
      },
    ],
  },
}

When I try to run multiple configurations, it appears that only one is executed.

I need postcss-loader to be added only in legacy

0

There are 0 best solutions below