这对于其他编译器工具链(例如GCC via)非常普遍-Werror
。
对于要求您遵循严格的准则,并希望将带有警告的构建视为错误并返回非零状态代码的情况非常有用。
我在Webpack的文档中找不到关于此的任何内容-是否可以通过CLI?
谢谢!
(截至撰写本文时,Webpack v4.41.5的最新版本)
有一个NPM软件包可以为您执行此操作:Webpack-错误警告
您可以自行配置以下几项:
stats: {
logging: 'info', // errors, warnings, and info messages
warnings: true
},
output: {
strictExportPresence: true // will throw error if import is missing, usually warning
}
否则,为此创建自己的函数:
if (compilation.warnings.length > 0) {
compilation.errors = compilation.errors.concat(compilation.warnings);
compilation.warnings = [];
}
compilation.children.forEach((child) => {
if (child.warnings.length > 0) {
child.errors = child.errors.concat(child.warnings);
child.warnings = [];
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句