Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selectively suppress webpack runtime errors? #527

Open
francisashley opened this issue Oct 3, 2023 · 1 comment
Open

Selectively suppress webpack runtime errors? #527

francisashley opened this issue Oct 3, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@francisashley
Copy link

francisashley commented Oct 3, 2023

We can disable all runtimeErrors from appearing in the error overlay with https://webpack.js.org/configuration/dev-server/#overlay:

module.exports = () => {
  return {
    devServer: {
      client: {
        overlay: {
          runtimeErrors: false
        }
      }
    }
  };
};

However attempting to provide the handler function

module.exports = () => {
  return {
    devServer: {
      client: {
        overlay: {
          runtimeErrors: (error) => {
              return true;
            }
          }
        }
      }
    }
  };
};

throws the error Invalid options object. Dev Server has been initialized using an options object that does not match the API schema..

Screenshot 2023-10-03 at 18 35 17

Is this easy to resolve? Thanks

CRACO version

7.1.0

@francisashley francisashley added the bug Something isn't working label Oct 3, 2023
@mayuresh82
Copy link

I have similar problem, except that my devServer config does not even seem to be taking effect.
craco.config.ts :

import webpack from "webpack";

module.exports = {
  webpack: {
    configure: (webpackConfig: webpack.Configuration, { env, paths }) => {
      webpackConfig.entry = "./src/index.tsx";
      return webpackConfig;
    },
  },
  devServer: {
    client: {
      overlay: {
        errors: true,
        warnings: false,
        runtimeErrors: (error) => {
          if (error.message.includes("ResizeObserver")) {
            return false;
          }
          return true;
        },
      },
    },
  },
};

I dont see any overlay iframes at all for runtime errors. Is this the right way to configure webpack devserver ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants