2

I have a vue-CLI project. Is there a simple way of viewing requests to the webpack dev server?

i.e. in the console after i've ran npm run dev and I get the message Your application is running here: http://localhost:8081 etc, I would like to see the hits to the webserver

I've added DEBUG='express:*'to my environment variables (windows) but it seems to make no difference.

Gordon Copestake
  • 1,616
  • 4
  • 21
  • 37
  • Possible duplicate of [unable to see request logs in webpack-dev-server](https://stackoverflow.com/questions/41822032/unable-to-see-request-logs-in-webpack-dev-server) – Matt Mar 12 '18 at 12:43
  • 1
    Yeah I saw that post, I did try to add DEBUG = EXPRESS:* to my environment variables but it made no difference – Gordon Copestake Mar 12 '18 at 12:50
  • Weird, on a fresh `vue init webpack` template, `env DEBUG="express:*" npm run dev` worked for me (your shell might not require `env` there) – Matt Mar 12 '18 at 12:57
  • I'm running windows(10) which probably breaks things, but the environment variable is definitely set, but no logging – Gordon Copestake Mar 12 '18 at 13:05

1 Answers1

2

Windows is funny. The standard approach is to use set VAR=val && webpack-dev-server... but that doesn't work on UNIX. I couldn't come up with a single command that would work on both a Windows and a UNIX shell.

Instead, to keep everything consistent, I'm now using the handy helper module cross-env

It's designed for exactly this purpose, and is easy to use. Just use cross-env where you'd typically use UNIX-style env, and away you go. Mine, for example, looks like:

"scripts": {
    "start": "cross-env DEBUG=express:router webpack-dev-server ...."
} 

This gives me portable request logging from webpack in development mode.

Stuart Watt
  • 5,242
  • 2
  • 24
  • 31