Skip to content

Modify Less module rule for all files in a directory #100

Open
@ppyoosef

Description

@ppyoosef

Hi

I am using antd as a UI toolkit. I want to implement style modules in my project. I tried like this

   `modifyLessRule(lessRule, context) {
      // You have to exclude these file suffixes first,
      // if you want to modify the less module's suffix
      // const relativePath = path.relative(context, resourcePath);
      console.log(context)
      lessRule.exclude = /\.less$/;
      return lessRule;

      
    },
    modifyLessModuleRule(lessModuleRule, context) {
      // Configure the file suffix
      lessModuleRule.test = /\.less$/;

      // Configure the generated local ident name.
      const cssLoader = lessModuleRule.use.find(loaderByName("css-loader"));
      cssLoader.options.modules = {
        localIdentName: "[local]_[hash:base64:5]",
      };

      return lessModuleRule;
    },`

But it applied to all less files including antd library. I want to apply only for styles inside the src folder. I know we can do by renaming all style files inside the src folder with some suffix (index.m.less) and change the regex.

I want to keep my style file as formatted now (index.less). Is there any option to apply modify rule only for my src folder?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions