craco 配置 style-resources-loader问题?

请问一下 , 使用craco配置webpack style-resources-loader ,想全局导入公用的less ,不起作用,代码如下, 是配置问题吗?

module.exports = {
  webpack: {
    module: {
      rules: [
        {
          test: /\.less$/,
          use: [
            "style-loader",
            "less-loader",
            "less-loader",
            {
              loader: "style-resources-loader",
              options: {
                patterns: path.resolve(
                  __dirname,
                  "./src/style/commonStyle.less"
                ),
                injector: "append",
              },
            },
          ],
        },
      ],
    },
    plugins: [
      new SimpleProgressWebpackPlugin(),
      //  new BundleAnalyzerPlugin()
    ],
  },
  babel: {
    plugins: [
      [
        "import",
        {
          libraryName: "antd",
          libraryDirectory: "es",
          style: true,
        },
      ],
    ],
  },
  plugins: [
    {
      plugin: CracoLessPlugin,
      options: {
        lessLoaderOptions: {
          lessOptions: {
            modifyVars: { "@primary-color": "red" },
            javascriptEnabled: true,
          },
        },
      },
    },
  ],
};
阅读 1.5k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏