dilanx / craco

Create React App Configuration Override, an easy and comprehensible configuration layer for Create React App.

Home Page:https://craco.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Selectively suppress webpack runtime errors?

francisashley opened this issue · comments

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

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 ?