我对打字稿和Webpack还是陌生的,尝试使用stats
对象来查看console.warn
,它在运行我的构建时确实显示,但是我想访问它。我不确定日志记录选项是否会向我显示我的console.warn
消息,但是我将无法访问它,以便我可以对其进行检查,如果我的消息没有退出,则使用非零退出代码退出构建console.warn是特定消息。
我正在使用webpack 4,我的build.ts
脚本如下:
const compiler = webpack(config);
compiler.run((err, stats) => {
console.log("stats logging", stats.toJson({ logging: 'warn' }));
});
src/commands/build.ts(28,51): error TS2345: Argument of type '{ logging: string; }' is not assignable to parameter of type 'boolean | "errors-only" | "errors-warnings" | "minimal" | "none" | "normal" | "verbose" | ToJsonOptionsObject | undefined'.
Object literal may only specify known properties, and 'logging' does not exist in type 'ToJsonOptionsObject'.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
我不确定这是否正确,我的警告和错误信息如下所示,表明它们为空:
stats.toJson('errors-only').errors // empty array
stats.toJson('errors-warnings').warnings // empty array
任何人都可以指出我正确的方向。