The content of this section is derived from the content of the following links and is subject to the CC BY 4.0 license.
The following contents can be assumed to be the result of modifications and deletions based on the original contents if not specifically stated.
Inline matchResource allows you to dynamically change the matching rules when loading resources. You can set the matchResource
for a module specifier by prefixing <match-resource>!=!
to the module specifier.
When a matchResource
is set, it will be used to match with the module.rules
instead of the original resource. This can be useful if further loaders should be applied to the resource, or if the module type needs to be changed.
It is not recommended to use this syntax in source code. Inline request syntax is intended to only be used by loader generated code. Not following this recommendation will make your code Rspack-specific and non-standard.
A loader could transform the file into the following file and use the matchResource
to apply the user-specified CSS processing rules:
This will add a dependency to extract-style-loader/getStyles!./file.js
and treat the result as file.js.css
.
Because module.rules
has a rule matching /\.css$/
and it will apply to this dependency.
The loader could look like this: