Log to node console or debug during webpack build

2020-08-25 06:04发布

问题:

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

回答1:

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.