IgnorePlugin

このプラグインは、正規表現に一致する import または require の呼び出しに対するモジュールの生成を阻止します。

new rspack.IgnorePlugin(options);

オプション

| {
    /** A RegExp to test the resource against. */
    resourceRegExp: RegExp;
    /** A RegExp to test the context (directory) against. */
    contextRegExp?: RegExp;
  }
| {
    /** A Filter function that receives `resource` and `context` as arguments, must return boolean. */
    checkResource: (resource: string, context: string) => boolean;
  }
  • デフォルト: undefined

次の設定を使用する場合

rspack.config.js
const rspack = require('@rspack/core');
module.exports = {
  plugins: [
    new rspack.IgnorePlugin({
      resourceRegExp: /^\.\/locale$/,
      contextRegExp: /moment$/,
    });
  ],
};

これは、「moment」で終わる任意のディレクトリからの './locale' に一致する require ステートメントは無視されることを意味します。

このページ内