基础设施日志配置
基础设施日志配置
基础设施级别日志记录的选项。
infrastructureLogging.appendOnly
5.31.0+
boolean
将内容追加到输出末尾,而不是更新已有输出,适用于状态消息。此选项仅在未提供自定义 console 时使用。
webpack.config.js
js
export default {
// ...
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
5.31.0+
boolean
为基础设施级别日志记录启用彩色输出。此选项仅在未提供自定义 console 时使用。
webpack.config.js
js
export default {
// ...
infrastructureLogging: {
colors: true,
level: "verbose",
},
plugins: [
(compiler) => {
const logger = compiler.getInfrastructureLogger("MyPlugin");
logger.log("this output will be colorful");
},
],
};
infrastructureLogging.console
5.31.0+
Console
自定义用于基础设施级别日志记录的 console。
webpack.config.js
js
export default {
// ...
infrastructureLogging: {
console: yourCustomConsole(),
},
};
infrastructureLogging.debug
string boolean = false RegExp function(name) => boolean [string, RegExp, function(name) => boolean]
启用指定记录器(例如插件或 loader)的调试信息。类似于 stats.loggingDebug 选项,但针对基础设施。默认为 false。
webpack.config.js
js
export default {
// ...
infrastructureLogging: {
level: "info",
debug: ["MyPlugin", /MyPlugin/, (name) => name.contains("MyPlugin")],
},
};
infrastructureLogging.level
string = 'info' : 'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose'
启用基础设施日志记录输出。类似于 stats.logging 选项,但针对基础设施。默认为 'info'。
可选值:
'none'- 禁用日志记录'error'- 仅错误'warn'- 仅错误和警告'info'- 错误、警告和信息消息'log'- 错误、警告、信息消息、日志消息、分组、清除。折叠的分组以折叠状态显示。'verbose'- 记录除 debug 和 trace 之外的所有内容。折叠的分组以展开状态显示。
webpack.config.js
js
export default {
// ...
infrastructureLogging: {
level: "info",
},
};
infrastructureLogging.progress
5.109.0+
boolean | 'auto' = false
显示内置构建进度,无需手动添加 ProgressPlugin。'auto' 仅在交互式终端(TTY)中显示进度条。当启用了 experiments.futureDefaults 时,其默认值为 'auto'。
进度条通过默认的日志记录 stream 渲染,因此当提供了自定义 console 时,它不会生效。
这会取代 WebpackBar 等第三方进度插件。
webpack.config.js
js
export default {
// ...
infrastructureLogging: {
progress: "auto",
},
};
infrastructureLogging.stream
5.31.0+
NodeJS.WritableStream = process.stderr
用于日志记录输出的流。默认为 process.stderr。此选项仅在未提供自定义 console 时使用。
webpack.config.js
js
export default {
// ...
infrastructureLogging: {
stream: process.stderr,
},
};
提示: 当为 TTY 流时,
colors会被启用,appendOnly会被禁用;反之亦然。
帮助我们改进文档
发现翻译问题或内容错误?请告诉我们。
