gpt4 book ai didi

javascript - webpack 通过 yarn : stop process and exit code 1 on warning

转载 作者:行者123 更新时间:2023-11-29 15:12:22 25 4
gpt4 key购买 nike

使用 Webpack 运行构建过程时,我收到了一些警告。我考虑了一些警告错误,IMO,它应该停止构建过程。

> yarn build:staging
yarn run v1.10.1
$ webpack --env.staging --env.NODE_ENV=staging
Version: webpack 4.23.1

[...]

[795] ./src/index.css 1.05 KiB {0} [built]
+ 793 hidden modules

WARNING in ./src/assets/banner/3.jpg
Module build failed (from ./node_modules/image-webpack-loader/index.js):
Error: Command failed: /home/circleci/repo/node_modules/mozjpeg/vendor/cjpeg
/home/circleci/repo/node_modules/mozjpeg/vendor/cjpeg: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory


at Promise.all.then.arr (/home/circleci/repo/node_modules/imagemin-mozjpeg/node_modules/execa/index.js:236:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ ./src/assets/banner sync ^\.\/.*\.jpg$ ./3.jpg
@ ./src/scenes/home/index.js
@ ./src/router.js
@ ./src/index.js
@ multi babel-polyfill ./src/index.js

[...]

Done in 26.03s.

这个“警告”应该停止整个过程并退出。 有没有办法告诉以 yarn 作为驱动程序的 webpack 在出现某种警告时停止(并返回错误代码)? 我的 CI 流程认为一切正常,这不是我预期的行为.

最佳答案

您可以从 Webpack 实例的 stats 对象访问 errorswarnings,然后选择拒绝/退出进程:https://github.com/webpack/docs/wiki/node.js-api

例如:

if(stats.errors.length > 0 || process.warning.length > 0) {
process.exit()

关于javascript - webpack 通过 yarn : stop process and exit code 1 on warning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53279671/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com