ResolveLoader

This configuration item is consistent in type with resolve, but this setting only affects the resolution of loaders.

  • Type: Consistent with resolve
  • Default:
{
  conditionNames: ["loader", "require", "node"],
  exportsFields: ["exports"],
  mainFields: ["loader", "main"],
  extensions: [".js"],
  mainFiles: ["index"]
}

Example

For instance, if you are developing a loader and want to showcase its usage from a user's perspective in an example, you can write:

rspack.config.js
module.exports = {
  resolveLoader: {
    alias: {
      'amazing-loader': require.resolve('path-to-your-amazing-loader'),
    },
  },
};

Then, in the example code, you can write:

require('!!amazing-loader!./amazing-file.js');
Inline Loaders

The loader mentioned above uses the syntax of inline loaders. For details, please refer to here.

ON THIS PAGE