在 webpack 构建期间登录到节点控制台或调试 [英] Log to node console or debug during webpack build
问题描述
在 webpack 构建过程中调试的最佳实践是什么?入口脚本中的任何 console.log 都不会输出到节点控制台.
What is the best practice for debugging during webpack build process? Any console.log in the entry script doesnt output to node console.
推荐答案
从 webpack 的当前版本(2019 年 9 月)开始,如果您进行构建而不是启动开发服务器,console.log 将输出到 std out (即节点控制台).
As of the current version of webpack (September 2019), if you do a build instead of launch a dev server, console.log will output to std out (i.e. the node console).
只需确保您正在执行完整构建(即npm run build")而不是开发服务器(即npm run dev").
Just make sure you are doing a full build (i.e. "npm run build") instead of a dev server (i.e. "npm run dev").
在许多情况下,开发服务器在编译过程中禁用 console.logs,和/或进度条更新的方式,console.log 字符串被覆盖,因此您永远看不到它们.
The dev server disables console.logs during the compile process in many circumstances, and/or the way the progress bar updates, the console.log strings are overwritten so you never see them.
这篇关于在 webpack 构建期间登录到节点控制台或调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!