CC 4.0 授權

本節內容衍生自以下連結的內容,並受 CC BY 4.0 授權條款約束。

如果沒有特別說明,以下內容可以假定為基於原始內容進行修改和刪除的結果。

InfrastructureLogging

用於基礎架構層級日誌記錄的選項。通常用於與編譯無關的日誌。

infrastructureLogging.appendOnly

  • 類型: boolean

將行附加到輸出,而不是更新現有輸出,這對於狀態訊息很有用。此選項僅在未提供自訂 console 時使用。

rspack.config.js
module.exports = {
  //...
  infrastructureLogging: {
    appendOnly: true,
    level: 'verbose',
  },
  plugins: [
    compiler => {
      const logger = compiler.getInfrastructureLogger('MyPlugin');
      logger.status('first output'); // this line won't be overridden with `appendOnly` enabled
      logger.status('second output');
    },
  ],
};

infrastructureLogging.colors

  • 類型: boolean

為基礎架構層級的日誌記錄啟用彩色輸出。此選項僅在未提供自訂 console 時使用。

rspack.config.js
module.exports = {
  //...
  infrastructureLogging: {
    colors: true,
    level: 'verbose',
  },
  plugins: [
    compiler => {
      const logger = compiler.getInfrastructureLogger('MyPlugin');
      logger.log('this output will be colorful');
    },
  ],
};

infrastructureLogging.console

  • 類型: Console
  • 預設值: Console

自訂用於基礎架構層級日誌記錄的 console。

rspack.config.js
module.exports = {
  //...
  infrastructureLogging: {
    console: yourCustomConsole(),
  },
};

infrastructureLogging.debug

  • 類型: boolean | RegExp | function(name) => boolean | [string, RegExp, function(name) => boolean]
  • 預設值: 'false'

啟用指定記錄器(例如外掛或載入器)的除錯資訊。與 stats.loggingDebug 選項類似,但用於基礎架構。預設為 false

rspack.config.js
module.exports = {
  //...
  infrastructureLogging: {
    level: 'info',
    debug: ['MyPlugin', /MyPlugin/, name => name.contains('MyPlugin')],
  },
};

infrastructureLogging.level

  • 類型: 'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose'
  • 預設值: 'info'

啟用基礎架構日誌輸出。與 (stats.logging)[/config/stats#statslogging] 選項類似,但用於基礎架構。預設為 'info'

可能的值

  • 'none' - 停用日誌記錄
  • 'error' - 僅限錯誤
  • 'warn' - 僅限錯誤和警告
  • 'info' - 錯誤、警告和資訊訊息
  • 'log' - 錯誤、警告、資訊訊息、日誌訊息、群組、清除。摺疊的群組以摺疊狀態顯示。
  • 'verbose' - 記錄除除錯和追蹤外的所有內容。摺疊的群組以展開狀態顯示。
rspack.config.js
module.exports = {
  //...
  infrastructureLogging: {
    level: 'info',
  },
};

infrastructureLogging.stream

  • 類型: NodeJS.WritableStream
  • 預設值: process.stderr

用於記錄輸出的串流。預設為 process.stderr。此選項僅在未提供自訂 console 時使用。

rspack.config.js
module.exports = {
  //...
  infrastructureLogging: {
    stream: process.stderr,
  },
};