Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log to node console or debug during webpack build

What is the best practice for debugging during webpack build process? Any console.log in the entry script doesnt output to node console.

like image 667
Draculater Avatar asked Jun 10 '15 01:06

Draculater


People also ask

How do you get to the console log in webpack?

log printed in your terminal you can add a console. log inside webpack. config file. If you are not providing the webpack-dev-server a port your app should run on 80 so opening the browser there and opening the browser console and you should be able to see the "starting!

How do I debug a webpack file?

Click the "inspect" link under each script to open a dedicated debugger or the Open dedicated DevTools for Node link for a session that will connect automatically. You can also check out the NiM extension, a handy Chrome plugin that will automatically open a DevTools tab every time you --inspect a script.

Does console log slow down Nodejs?

As said above, the console. log is asynchronous and non-blocking, so it would not slow your application too much except one tick for the function invocation. But it is a good habit to use some module to turn some logs of certain level off when deploy it in production instead of using console.


1 Answers

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).

Just make sure you are doing a full build (i.e. "npm run build") instead of a dev server (i.e. "npm run dev").

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.

like image 55
Nick Steele Avatar answered Nov 09 '22 02:11

Nick Steele