craco vs customize-cra vs react-app-rewired
Customizing Create React App
cracocustomize-crareact-app-rewiredSimilar Packages:

Customizing Create React App

Customizing Create React App (CRA) is essential for developers who need to modify the default configuration of a CRA project without ejecting. Ejecting exposes all configuration files, making them editable but also complicating future updates. Instead, tools like craco, customize-cra, and react-app-rewired allow for non-intrusive modifications to Webpack, Babel, ESLint, and other settings, enabling customization while keeping the CRA setup manageable. These tools are particularly useful for adding plugins, loaders, or changing settings to meet specific project requirements without losing the benefits of CRA's zero-config approach.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
craco0790.9 kB0-MIT
customize-cra02,780-1156 years agoMIT
react-app-rewired09,87948.9 kB18-MIT

Feature Comparison: craco vs customize-cra vs react-app-rewired

Configuration Method

  • craco:

    craco uses a dedicated configuration file (craco.config.js) that allows for centralized management of all customizations, including Webpack, Babel, and ESLint. This approach promotes better organization and clarity, especially for larger projects.

  • customize-cra:

    customize-cra does not require a separate configuration file. Instead, it provides a set of functions that can be used to modify the existing Webpack configuration directly within the config-overrides.js file. This method is more flexible and allows for quick, targeted changes without the need for extensive setup.

  • react-app-rewired:

    react-app-rewired allows for configuration overrides by replacing the react-scripts entry point in package.json. It does not require a separate configuration file, making it easy to implement. However, it relies on the existing CRA configuration structure, which may limit the extent of customization.

Ease of Use

  • craco:

    craco is user-friendly and well-documented, making it easy for developers to implement and understand the customization process. Its structured approach reduces the learning curve and helps maintain consistency across the project.

  • customize-cra:

    customize-cra is easy to use for developers familiar with Webpack. Its plugin-based architecture allows for quick integration of customizations, but it may require some understanding of Webpack configuration to use effectively.

  • react-app-rewired:

    react-app-rewired is straightforward and quick to set up, making it ideal for developers who need to make simple changes without a steep learning curve. Its simplicity, however, may limit more complex customizations.

Community and Ecosystem

  • craco:

    craco has a growing community and ecosystem, with active maintenance and contributions. It is widely adopted for its comprehensive feature set and flexibility, making it a reliable choice for long-term projects.

  • customize-cra:

    customize-cra is popular within the CRA community, especially among developers who need targeted Webpack customizations. It is well-maintained and has a supportive community, but it is more niche compared to craco and react-app-rewired.

  • react-app-rewired:

    react-app-rewired has a large user base and is well-established in the CRA ecosystem. It is actively maintained, and its simplicity has led to widespread adoption for projects requiring quick and easy configuration overrides.

Code Example

  • craco:

    Example of craco configuration:

    // craco.config.js
    module.exports = {
      webpack: {
        configure: (webpackConfig) => {
          // Modify webpackConfig as needed
          return webpackConfig;
        },
      },
      babel: {
        presets: [], // Add custom Babel presets
        plugins: [], // Add custom Babel plugins
      },
      eslint: {
        enable: true, // Enable custom ESLint configuration
        mode: 'extends', // Use extends mode
        configure: (eslintConfig) => {
          // Modify eslintConfig as needed
          return eslintConfig;
        },
      },
    };
    
  • customize-cra:

    Example of customize-cra usage:

    // config-overrides.js
    const { override, addWebpackPlugin } = require('customize-cra');
    const MyCustomPlugin = require('./path/to/my-custom-plugin');
    
    module.exports = override(
      addWebpackPlugin(new MyCustomPlugin()), // Add custom Webpack plugin
    );
    
  • react-app-rewired:

    Example of react-app-rewired setup:

    // package.json
    {
      "scripts": {
        "start": "react-app-rewired start",
        "build": "react-app-rewired build",
        "test": "react-app-rewired test"
      }
    }
    

How to Choose: craco vs customize-cra vs react-app-rewired

  • craco:

    Choose craco if you want a comprehensive solution that supports multiple configuration overrides (Webpack, Babel, ESLint) through a single craco.config.js file. It is ideal for teams looking for a structured and maintainable way to customize CRA without ejecting.

  • customize-cra:

    Select customize-cra if you prefer a lightweight, plugin-based approach to modify Webpack configurations. It works best when combined with react-app-rewired and is suitable for projects that need specific, targeted changes without a full configuration overhaul.

  • react-app-rewired:

    Opt for react-app-rewired if you need a simple way to override CRA's Webpack configuration without ejecting. It allows for quick modifications by replacing the react-scripts entry point, making it great for smaller projects or when only minor adjustments are needed.

README for craco

craco

npm GitHub stars

high level api for interacting with webpack config

Features

  • supports webpack v4

Installation

npm install --save craco

Usage

Submit an issue

System Requirements

Node.js

Support

Submit an issue

Contributing

Review the guidelines for contributing

License

MIT License

Jam Risser © 2019

Changelog

Review the changelog

Credits

Support on Liberapay

A ridiculous amount of coffee ☕ ☕ ☕ was consumed in the process of building this project.

Add some fuel if you'd like to keep me going!

Liberapay receiving Liberapay patrons