SolidZORO / next-plugin-antd-less

🎩 Use Antd (Less) with Next.js v12, Zero Dependency on other Next-Plugins.
MIT License
345 stars 48 forks source link

How to get rid of file matching *.module.less? #28

Closed sunhak-hout closed 3 years ago

sunhak-hout commented 3 years ago

I try this plugin and it works like a charm to me. Howerver, I'm facing one issue that I want to use style.less instead of style.module.less. I try some configuration with cssLoaderOptions as below, but seems nothing work for me. Any advice or solution on this?

// next.config.js
const withAntdLess = require("next-plugin-antd-less");

module.exports = withAntdLess({
  // optional
  lessVarsFilePath: "./src/styles/theme/variables.less",

  // optional https://github.com/webpack-contrib/css-loader#object
  cssLoaderOptions: {
    modules: {
      auto: (resourcePath) => resourcePath.endsWith(".less"),
    },
  },

  webpack(config) {
    return config;
  },
});
SolidZORO commented 3 years ago

I think you see the configuration here https://webpack.js.org/loaders/css-loader/#function-2

In this code snippet.

https://github.com/SolidZORO/next-plugin-antd-less/blob/master/index.js#L96-L115

You can see that the last line is auto: true and you can't override that with nextConfig.cssLoaderOptions.

Because this abc.less and abc.module.less naming convention is a best practice for css modules, and I'm not going to override auto.

So you can fork and change this configuration.


我想你是在这里看到配置的 https://webpack.js.org/loaders/css-loader/#function-2

在这个代码片段中:

https://github.com/SolidZORO/next-plugin-antd-less/blob/master/index.js#L96-L115

你可以看到,最后一行是 auto: true 而且你不能用 nextConfig.cssLoaderOptions 覆盖。

因为这 abc.lessabc.module.less 的命名方式是 css modules 的最佳实践,我不打算把 auto 覆盖掉。

所以你可以 fork 然后修改这个配置。

sunhak-hout commented 3 years ago

@SolidZORO I didn't know the auto option is always set to true. Thanks for the reply. Really appreciate that :)