enable --display-error-details in webpack to debug module imports

8.7k Views Asked by At

working on an issue where I need to enable this webpack.stats options for the cli for debugging purposes.

On the base webpack.config there is no stats options enabled so it needs to be done another way.

The devServer is also separated into it's own .js file and not listed under the default webpack.config

I've tried to directly add this setting into the base webpack configuration, I've also researched and reviewed the functionality under dev-server to see if it's a setting I can just add a line of code to, but no luck. For example I reviewed into stats.hasErrors() function and learned about the option

stats.toJson({
errorDetails: true
})

What I believe to be the relevant parts of the code that need to be updated dev-server.js

).then(config => {
    if (options.debugWebpack) {
      logConfig('Manager webpack config', config, logger);
    }
    return new Promise((resolve, reject) => {
      webpack(config).watch(
        {
          aggregateTimeout: 1,
        },
        (err, stats) => {
          managerTotalTime = process.hrtime(startTime);
          if (!resolved && (err || stats.hasErrors())) {
            const error = new Error('Manager build is broken');
            error.error = err;
            error.close = true;
            error.stats = stats;
            logger.line();
            logger.line();

I want to be able to run something like the following:

yarn storybook --display-error-details

Link to the repo: https://github.com/storybookjs/storybook/tree/next/lib/core/src/server Thanks for any help provided!

1

There are 1 best solutions below

0
On

So I got an approval from the repo by doing the following:
dev-server.js

 managerTotalTime = process.hrtime(startTime);
          if (!resolved && (err || stats.hasErrors())) {
            const error = new Error('Manager build is broken');
            error.error = err;
            error.close = true;
            error.stats = stats;
            stats.toJson({
               errorDetails: true
            })
            logger.line();
            logger.line();