Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: builtins.css.modules support auto config #2273

Closed
hzura opened this issue Mar 15, 2023 · 3 comments
Closed

[Feature Request]: builtins.css.modules support auto config #2273

hzura opened this issue Mar 15, 2023 · 3 comments
Assignees
Labels
contrib: medium feat New feature or request good first issue Good for newcomers

Comments

@hzura
Copy link

hzura commented Mar 15, 2023

What problem does this feature solve?

Currently, if you need to support both .less and .module.less files in the project, you need to configure their types separately like below. (plz forgive me if I have used them incorrectly)

{
  test: /\.less$/,
  use: [{
	  loader: 'less-loader',
  }],
  type: 'css/module',
},
{
  test: /^(.(?!\.module))+\.less$/,
  use: [{
	  loader: 'less-loader',
  },],
  type: 'css',
},

I hope that builtins.css.modules config can support option auto like css-loader, allowing automatic differentiation using regular expressions (as the cost of using a function may be high at the moment)
preference: https://webpack.js.org/loaders/css-loader/#modules

What does the proposed API of configuration look like?

type BuiltinsCssModules = {
  localsConvention?:
    | 'asIs'
    | 'camelCase'
    | 'camelCaseOnly'
    | 'dashes'
    | 'dashesOnly';
  localIdentName?: string;
  exportsOnly?: boolean;
  auto?: boolean | RegExp;
};
@hzura hzura added the feat New feature or request label Mar 15, 2023
@hzura hzura changed the title [Feature Request]: builtins.css.modules support auto config [Feature Request]: builtins.css.modules support auto config Mar 15, 2023
@hardfist
Copy link
Contributor

waiting for webpack/webpack#16572 resolved

@evertzz
Copy link

evertzz commented Mar 22, 2023

I wonder how to support module.less, the configuration above does't work

@hardfist
Copy link
Contributor

since webpack/webpack#16577 landed, we can continue supporting it now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contrib: medium feat New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants