timarney / react-app-rewired

Override create-react-app webpack configs without ejecting
MIT License
9.77k stars 425 forks source link

CRA 5 #599

Closed dogeow closed 2 years ago

dogeow commented 2 years ago
yarn add --exact react-scripts@5.0.0

Example➜~/WebstormProjects/antic(master✗)» yarn start [11:53:03] yarn run v1.22.4 $ react-app-rewired start Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.

dawnmist commented 2 years ago

What is in your config-overrides file? What webpack modules/plugins are you adding to the CRA configuration?

The error message given is saying that the devServer configuration overrides specified contain an invalid option writeToDisk. That'll either be something you've added yourself to your config-overrides.js file, or something that is being added as a result of a webpack plugin/module that you're adding. It's a configuration error in your local environment/project, not a bug in react-app-rewired as react-app-rewired doesn't itself change the CRA configuration (it simply enables you to change the configuration).

dogeow commented 2 years ago
/* eslint-disable react-hooks/rules-of-hooks */
const { override, useBabelRc, overrideDevServer } = require("customize-cra");

const devServerConfig = () => (config) => {
  return {
    ...config,
    writeToDisk: true,
  };
};

module.exports = {
  webpack: override(useBabelRc()),
  devServer: overrideDevServer(devServerConfig()),
};