无法在webpack-dev-server中查看请求日志 [英] unable to see request logs in webpack-dev-server

查看:890
本文介绍了无法在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.

这篇关于无法在webpack-dev-server中查看请求日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆