Options 配置

RsdoctorRspackPlugin 插件

RsdoctorRspackPlugin 类由 @rsdoctor/rspack-plugin 导出,配置项是 RsdoctorRspackPluginOptions

cjs
esm
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');

new RsdoctorRspackPlugin({
  /** RsdoctorRspackPluginOptions */
});

RsdoctorWebpackPlugin 插件

RsdoctorWebpackPlugin 类由 @rsdoctor/webpack-plugin 导出,配置项是 RsdoctorWebpackPluginOptions

cjs
esm
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');

new RsdoctorWebpackPlugin({
  /** RsdoctorWebpackPluginOptions */
});

Options

类型: Object

这个 OptionsRsdoctorWebpackPluginRsdoctorRspackPlugin 的配置项。它包含以下属性值:

disableClientServer

  • Type: boolean
  • Optional: true
  • Default: false
TIP

建议在 CI 环境下将 disableClientServer 设置为 true,否则启动的服务会卡住 pipeline 流程.

是否需要自动打开 Rsdoctor 报告页面。如果你不需要在浏览器内查看本次 Rsdoctor 提供的分析报告,则可以开启这个配置项。

features

features values

TIP

如果出现了 out of memory 的报错,可以尝试:

  1. 打开 lite 模式。
  2. 增大 node 内存上限,例如:NODE_OPTIONS=--max-old-space-size=8096。
  • 原因:因为构建过程中,缓存了源码信息,超过了内存,所以开启 lite 模式可以缓解。
  • 区别:lite 模式和普通模式的区别就是不再缓存源码信息,只缓存打包后的代码信息,这样分析页面上的代码也将是打包后的。

features 属性是用于分析功能开关的,具体的功能项如下:

  • loader:Loaders 耗时及代码编译变化分析,默认开启。
  • plugins:Plugins 调用以及耗时分析,默认开启。
  • bundle:构建产物分析,默认开启。
  • resolver:resolver 分析,默认关闭。
  • lite: lite 模式。lite 模式和普通模式的区别就是不再缓存源码信息,只缓存打包后的代码信息,这样分析页面上的代码也将是打包后的。默认普通模式。

所以,默认配置是开启了 Bundle 分析能力、 Loader he Plugin 构建时分析。没有开启 Resolver 分析能力, Rspack 暂不支持 Resolver 分析能力。

features types

  • 如果你将 features 设置为数组类型,该插件只会开启你在 features 数组中定义的功能。
  • 如果你将 features 设置为简单对象类型,该插件只会关闭你在 features 对象中值为 false 的功能。

RsdoctorWebpackPluginFeatures

features 类型如下:

interface RsdoctorWebpackPluginFeatures {
  /**
   * turn off it if you need not to analyze the executions of webpack loaders.
   * @default true
   */
  loader?: boolean;
  /**
   * turn off it if you need not to analyze the executions of webpack plugins.
   * @default true
   */
  plugins?: boolean;
  /**
   * turn off it if you need not to analyze the executions of resolver.
   * @default false
   */
  resolver?: boolean;
  /**
   * turn off it if you need not to analyze the output bundle.
   * @default true
   */
  bundle?: boolean;
  /**
   * turn on it if you just use lite mode. This mode do not have source codes.
   * @default false
   */
  lite?: boolean;
}

RsdoctorRspackPluginFeatures

features 类型如下:

interface RsdoctorRspackPluginFeatures {
  /**
   * turn off it if you need not to analyze the executions of webpack loaders.
   * @default true
   */
  loader?: boolean;
  /**
   * turn off it if you need not to analyze the executions of webpack plugins.
   * @default true
   */
  plugins?: boolean;
  /**
   * turn off it if you need not to analyze the output bundle.
   * @default true
   */
  bundle?: boolean;
  /**
   * turn on it if you just use lite mode. This mode do not have source codes.
   * @default false
   */
  lite?: boolean;
}