无法在webpack-dev-server中查看请求日志
我正在使用webpack-dev-server
在本地充当CDN服务器,以服务各种静态资产,例如CSS,JS,HTML等.
I am using webpack-dev-server
to act as a CDN server locally to serve various static assets like css, js, html etc.
一切正常,但出于调试目的,我看不到CDN服务器收到的请求.
Everything runs fine but for debugging purposes, I am unable to see the requests received by the CDN server.
webpack-dev-server
只是保持沉默,并且一旦编译了静态资产捆绑包,便不会显示任何信息/错误.
webpack-dev-server
just goes silent and doesn't show any info/errors once it has compiled the bundle of static assets.
我也通过了命令行帮助,但没有成功.
I went through the command line help too but with no success.
基本上,webpack-dev-server
使用express
生成Web服务器.要启用查看日志,需要根据express的要求设置DEBUG环境变量
Basically, webpack-dev-server
uses express
to spawn a webserver. To enable seeing logs, one needs to set DEBUG environment variable as required by express
export DEBUG='express:*'
这开始向我显示webpack-dev-server
收到的各种请求的日志.
This started showing me logs of various requests received by webpack-dev-server
.
要禁用日志,请再次将环境变量设置为空
To disable the logs, set the environment variable empty again
export DEBUG=
即使对于loopback
项目和任何其他使用express作为基础的NodeJS框架,此方法也适用.
This works even for loopback
projects and any other NodeJS frameworks which use express as base.