CC 4.0 License

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.

Other options

These are the remaining configuration options supported by rspack.

amd

  • Type: false | object
  • Default:false
INFO

Unlike webpack, where the default value of the amd option is {} (meaning AMD module dependency analysis is enabled by default), Rspack sets the default value of the amd option to false. This means AMD module dependency analysis is disabled by default in Rspack. This change was made because the usage of AMD modules is gradually decreasing. If your application requires it, you can enable this option by yourself.

Enable this option to support dependency analysis for AMD modules, which is helpful for compatibility with some older libraries written according to the AMD specification.

rspack.config.mjs
export default {
  amd: {}, // enable parsing AMD module dependencies
};

In addition, you can set the values of require.amd or define.amd through this configuration:

rspack.config.mjs
export default {
  amd: {
    jQuery: true, // `require.amd` and `define.amd` are set to `{ jQuery: true }`.
  },
};

bail

  • Type: boolean
  • Default:false

Fail out on the first error instead of tolerating it. By default Rspack will log these errors in red in the terminal, as well as the browser console when using HMR, but continue bundling. To enable it:

rspack.config.mjs
export default {
  bail: true,
};

This will force Rspack to exit its bundling process.

dependencies

  • Type: string[]
  • Default:undefined

A list of name defining all sibling configurations it depends on. Dependent configurations need to be compiled first.

In watch mode dependencies will invalidate the compiler when:

  1. the dependency has changed
  2. a dependency is currently compiling or invalid

Remember that current configuration will not compile until its dependencies are done.

rspack.config.mjs
export default [
  {
    name: 'client',
    target: 'web',
    // …
  },
  {
    name: 'server',
    target: 'node',
    dependencies: ['client'],
  },
];

ignoreWarnings

  • Type: (RegExp | ((warning: Error, Compilation: Compilation) => boolean))[]
  • Default:undefined

Tells Rspack to ignore specific warnings.

rspack.config.mjs
export default {
  //...
  ignoreWarnings: [/warning from compiler/, warning => true],
};

name

  • Type: string
  • Default:undefined

Name of the configuration. Used when loading multiple configurations.

rspack.config.mjs
export default {
  //...
  name: 'admin-app',
};

loader

  • Type: Record<string, any>
  • Default:undefined

Expose custom values into the loader context.

For example, you can define a new variable in the loader context:

rspack.config.mjs
export default {
  // ...
  loader: {
    answer: 42,
  },
};

Then use this.answer to get its value in the loader:

custom-loader.js
module.exports = function (source) {
  // ...
  console.log(this.answer); // will log `42` here
  return source;
};
TIP

You can override properties in the loader context as webpack copies all properties that are defined in the loader to the loader context.

profile

  • Type: boolean
  • Default:undefined

Capture a "profile" of the application, including statistics and hints, which can then be dissected using the Analyze tool. It will also log out a summary of module timings.