Skip to content

Pass resourceQuery to modules.auto callback #1566

Closed
@erropix

Description

@erropix

Modification Proposal

Pass the resourceQuery as a second argument to the modules.auto function callback.

type auto = boolean | regExp | ((resourcePath: string, resourceQuery: string) => boolean);

Expected Behavior / Situation

You should be able to return true or false based on the resource query. Specially with the vue-loader style module

Actual Behavior / Situation

You only have access to the resource path which doesn't include any information about if the module attribute is set in the style block or not.

The current workaround is to use conditional rules like shown here https://vue-loader.vuejs.org/guide/css-modules.html#opt-in-usage

But this solution is not optimal when there are multiple loaders applied to both CSS and Sass assets.

Please paste the results of npx webpack-cli info here, and mention other relevant information

System:
  OS: Windows 10 10.0.19045
  CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
  Memory: 17.48 GB / 31.91 GB
Binaries:
  Node: 20.10.0 - ~\scoop\apps\nodejs-lts\current\node.EXE
  Yarn: 1.22.19 - ~\scoop\apps\yarn\current\bin\yarn.CMD
  npm: 10.2.5 - ~\scoop\apps\nodejs-lts\current\bin\npm.CMD
Browsers:
  Edge: Chromium (120.0.2210.144)
  Internet Explorer: 11.0.19041.3636
Packages:
  copy-webpack-plugin: ^12.0.2 => 12.0.2
  css-loader: ^6.9.1 => 6.9.1
  postcss-loader: ^8.0.0 => 8.0.0
  sass-loader: ^14.0.0 => 14.0.0
  style-loader: ^3.3.4 => 3.3.4
  svgo-loader: ^4.0.0 => 4.0.0
  swc-minify-webpack-plugin: ^2.1.1 => 2.1.1
  vue-loader: ^17.4.2 => 17.4.2
  webpack: ^5.89.0 => 5.89.0
  webpack-bundle-analyzer: ^4.10.1 => 4.10.1
  webpack-cli: ^5.1.4 => 5.1.4
  webpack-dev-server: ^4.15.1 => 4.15.1
  webpack-manifest-plugin: ^5.0.0 => 5.0.0

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