webpack vs craco vs customize-cra vs react-app-rewired vs react-scripts vs vite
Web Development Build Tools
webpackcracocustomize-crareact-app-rewiredreact-scriptsviteSimilar Packages:

Web Development Build Tools

Build tools in web development are essential for automating tasks such as bundling, minifying, and optimizing code for production. They help streamline the development process by transforming source code into a format that can be efficiently served to users. These tools can handle various tasks like transpiling JavaScript, processing CSS, optimizing images, and managing dependencies. Popular build tools include Webpack, Vite, and Create React App (CRA) with its custom configurations. They play a crucial role in improving performance, reducing load times, and enhancing the overall user experience on websites and applications.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
webpack54,342,86665,8648.06 MB1472 days agoMIT
craco0790.9 kB0-MIT
customize-cra02,765-1146 years agoMIT
react-app-rewired09,84548.9 kB22-MIT
react-scripts0103,301116 kB2,4094 years agoMIT
vite082,0902.25 MB74810 days agoMIT

Feature Comparison: webpack vs craco vs customize-cra vs react-app-rewired vs react-scripts vs vite

Customization

  • webpack:

    webpack is known for its deep customization capabilities. It allows developers to configure every aspect of the bundling process, from loaders and plugins to output settings and module resolution. Webpack's configuration is highly flexible, enabling complex setups for large applications, making it the go-to choice for projects that require fine-grained control over the build process.

  • craco:

    craco allows for extensive customization of Create React App (CRA) configurations without ejecting. It lets you modify Webpack, Babel, ESLint, and other settings by simply adding a craco.config.js file to your project. This approach keeps your CRA setup intact while providing the flexibility to make necessary adjustments.

  • customize-cra:

    customize-cra provides a set of utilities to customize the Webpack configuration of Create React App (CRA) without ejecting. It works in conjunction with react-app-rewired and allows you to make targeted changes to the Webpack config, such as adding plugins, modifying loaders, or changing the output configuration. This package is ideal for developers who want to make specific adjustments to the CRA setup while keeping the rest of the configuration untouched.

  • react-app-rewired:

    react-app-rewired allows you to override the default configurations of Create React App (CRA) without ejecting. It enables you to customize the Webpack, Babel, and ESLint settings by modifying the config-overrides.js file in your project. This approach provides flexibility while maintaining the simplicity and ease of use of CRA, making it suitable for projects that require minor configuration changes without a complete overhaul.

  • vite:

    vite is designed for modern web development with a focus on speed and performance. It allows for easy customization of the build process through a simple configuration file (vite.config.js). Vite supports plugins, and you can customize various aspects of the build, such as the server, build output, and more, while keeping the configuration straightforward and intuitive.

Performance

  • webpack:

    webpack performance can vary based on configuration. While it is highly efficient for production builds, the development experience can be slower compared to Vite, especially with large projects. However, Webpack offers various optimization techniques, such as code splitting, tree shaking, and caching, to improve build times and runtime performance.

  • vite:

    vite is optimized for performance, especially during development. It uses native ES modules and a fast development server, resulting in instant server starts and lightning-fast hot module replacement (HMR). Vite's production builds are also highly optimized, making it one of the fastest build tools available.

Ease of Use

  • react-scripts:

    react-scripts provides a zero-configuration setup for React applications, making it extremely easy to use for beginners and experienced developers alike. It abstracts away all the complex configurations, allowing developers to focus on writing code without worrying about the underlying build process.

  • vite:

    vite offers a simple and intuitive setup, especially for new projects. Its configuration is straightforward, and it provides excellent documentation and examples, making it easy for developers to get started quickly.

Code Example

  • webpack:

    webpack Example

    // webpack.config.js
    const path = require('path');
    module.exports = {
      entry: './src/index.js',
      output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist'),
      },
      module: {
        rules: [
          {
            test: /.js$/,
            exclude: /node_modules/, 
            use: 'babel-loader',
          },
        ],
      },
    };
    
  • craco:

    craco Example

    // craco.config.js
    module.exports = {
      webpack: {
        configure: (webpackConfig) => {
          // Modify webpackConfig as needed
          return webpackConfig;
        },
      },
    };
    
  • customize-cra:

    customize-cra Example

    // config-overrides.js
    const { override, addWebpackPlugin } = require('customize-cra');
    const SomeWebpackPlugin = require('some-webpack-plugin');
    
    module.exports = override(
      addWebpackPlugin(new SomeWebpackPlugin())
    );
    
  • react-app-rewired:

    react-app-rewired Example

    // config-overrides.js
    module.exports = (config) => {
      // Modify the CRA config as needed
      config.output.filename = 'my-app.js';
      return config;
    };
    
  • vite:

    vite Example

    // vite.config.js
    import { defineConfig } from 'vite';
    
    export default defineConfig({
      server: {
        port: 3000,
      },
      build: {
        outDir: 'dist',
      },
    });
    

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

  • webpack:

    Choose webpack if you need a highly configurable and powerful bundler for complex applications. It allows for deep customization of the build process, making it suitable for large projects with specific requirements.

  • craco:

    Choose craco if you want to customize Create React App (CRA) configurations without ejecting. It allows for easy modifications while keeping the CRA setup intact, making it ideal for teams that want to maintain a standard CRA project with some customizations.

  • customize-cra:

    Select customize-cra if you are using Create React App and want to make specific configuration changes without ejecting. It works alongside react-app-rewired to provide a set of utilities for customizing Webpack configurations easily.

  • react-app-rewired:

    Use react-app-rewired if you want to override Create React App (CRA) configurations without ejecting. It allows you to modify the Webpack config and other settings in a non-intrusive way, making it suitable for projects that need custom configurations while retaining CRA's benefits.

  • react-scripts:

    Stick with react-scripts if you prefer a zero-configuration setup for your React project. It provides all the necessary build tools, scripts, and configurations out of the box, allowing you to focus on development without worrying about the underlying setup.

  • vite:

    Opt for vite if you are starting a new project and want a fast, modern build tool with instant server start and hot module replacement (HMR). It leverages native ES modules for faster development and provides excellent performance for production builds.

README for webpack



npm

node builds1 dependency-review coverage pkg.pr.new PR's welcome compatibility-score downloads install-size backers sponsors contributors discussions discord LFX Health Score

webpack

Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.

Table of Contents

Install

Install with npm:

npm install --save-dev webpack

Install with yarn:

yarn add webpack --dev

Introduction

Webpack is a bundler for modules. The main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.

TL;DR

  • Bundles ES Modules, CommonJS, and AMD modules (even combined).
  • Can create a single bundle or multiple chunks that are asynchronously loaded at runtime (to reduce initial loading time).
  • Dependencies are resolved during compilation, reducing the runtime size.
  • Loaders can preprocess files while compiling, e.g. TypeScript to JavaScript, Handlebars strings to compiled functions, images to Base64, etc.
  • Highly modular plugin system to do whatever else your application requires.

Learn about webpack through videos!

Get Started

Check out webpack's quick Get Started guide and the other guides.

Browser Compatibility

Webpack supports all browsers that are ES5-compliant (IE8 and below are not supported). Webpack also needs Promise for import() and require.ensure(). If you want to support older browsers, you will need to load a polyfill before using these expressions.

Concepts

Plugins

Webpack has a rich plugin interface. Most of the features within webpack itself use this plugin interface. This makes webpack very flexible.

NameStatusInstall SizeDescription
mini-css-extract-pluginmini-css-npmmini-css-sizeExtracts CSS into separate files. It creates a CSS file per JS file which contains CSS.
compression-webpack-plugincompression-npmcompression-sizePrepares compressed versions of assets to serve them with Content-Encoding
html-bundler-webpack-pluginbundler-npmbundler-sizeRenders a template (EJS, Handlebars, Pug) with referenced source asset files into HTML.
html-webpack-pluginhtml-plugin-npmhtml-plugin-sizeSimplifies creation of HTML files (index.html) to serve your bundles
pug-pluginpug-plugin-npmpug-plugin-sizeRenders Pug files to HTML, extracts JS and CSS from sources specified directly in Pug.

Loaders

Webpack enables the use of loaders to preprocess files. This allows you to bundle any static resource way beyond JavaScript. You can easily write your own loaders using Node.js.

Loaders are activated by using loadername! prefixes in require() statements, or are automatically applied via regex from your webpack configuration.

JSON

NameStatusInstall SizeDescription
cson-npmcson-sizeLoads and transpiles a CSON file

Transpiling

NameStatusInstall SizeDescription
babel-npmbabel-sizeLoads ES2015+ code and transpiles to ES5 using Babel
type-npmtype-sizeLoads TypeScript like JavaScript
coffee-npmcoffee-sizeLoads CoffeeScript like JavaScript

Templating

NameStatusInstall SizeDescription
html-npmhtml-sizeExports HTML as string, requires references to static resources
pug-npmpug-sizeCompiles Pug to a function or HTML string, useful for use with Vue, React, Angular
md-npmmd-sizeCompiles Markdown to HTML
posthtml-npmposthtml-sizeLoads and transforms a HTML file using PostHTML
hbs-npmhbs-sizeCompiles Handlebars to HTML

Styling

NameStatusInstall SizeDescription
<style>style-npmstyle-sizeAdd exports of a module as style to DOM
css-npmcss-sizeLoads CSS file with resolved imports and returns CSS code
less-npmless-sizeLoads and compiles a LESS file
sass-npmsass-sizeLoads and compiles a Sass/SCSS file
stylus-npmstylus-sizeLoads and compiles a Stylus file
postcss-npmpostcss-sizeLoads and transforms a CSS/SSS file using PostCSS

Frameworks

NameStatusInstall SizeDescription
vue-npmvue-sizeLoads and compiles Vue Components
polymer-npmpolymer-sizeProcess HTML & CSS with preprocessor of choice and require() Web Components like first-class modules
angular-npmangular-sizeLoads and compiles Angular 2 Components
riot-npmriot-sizeRiot official webpack loader
svelte-npmsvelte-sizeOfficial Svelte loader

Performance

Webpack uses async I/O and has multiple caching levels. This makes webpack fast and incredibly fast on incremental compilations.

Module Formats

Webpack supports ES2015+, CommonJS and AMD modules out of the box. It performs clever static analysis on the AST of your code. It even has an evaluation engine to evaluate simple expressions. This allows you to support most existing libraries out of the box.

Code Splitting

Webpack allows you to split your codebase into multiple chunks. Chunks are loaded asynchronously at runtime. This reduces the initial loading time.

Optimizations

Webpack can do many optimizations to reduce the output size of your JavaScript by deduplicating frequently used modules, minifying, and giving you full control of what is loaded initially and what is loaded at runtime through code splitting. It can also make your code chunks cache friendly by using hashes.

Developer Tools

If you're working on webpack itself, or building advanced plugins or integrations, the tools below can help you explore internal mechanics, debug plugin life-cycles, and build custom tooling.

Instrumentation

NameStatusDescription
tapable-tracertapable-tracer-npmTraces tapable hook execution in real-time and collects structured stack frames. Can export to UML for generating visualizations.

Contributing

We want contributing to webpack to be fun, enjoyable, and educational for anyone, and everyone. We have a vibrant ecosystem that spans beyond this single repo. We welcome you to check out any of the repositories in our organization or webpack-contrib organization which houses all of our loaders and plugins.

Contributions go far beyond pull requests and commits. Although we love giving you the opportunity to put your stamp on webpack, we also are thrilled to receive a variety of other contributions including:

To get started have a look at our documentation on contributing.

Creating your own plugins and loaders

If you create a loader or plugin, we would <3 for you to open source it, and put it on npm. We follow the x-loader, x-webpack-plugin naming convention.

Support

We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of its flexibility, webpack isn't always the easiest entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways to improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!

If you're just getting started, take a look at our new docs and concepts page. This has a high level overview that is great for beginners!!

If you have discovered a 🐜 or have a feature suggestion, feel free to create an issue on GitHub.

Current project members

For information about the governance of the webpack project, see GOVERNANCE.md.

TSC (Technical Steering Committee)

Maintenance

This webpack repository is maintained by the Core Working Group.

Sponsoring

Most of the core team members, webpack contributors and contributors in the ecosystem do this open source work in their free time. If you use webpack for a serious task, and you'd like us to invest more time on it, please donate. This project increases your income/productivity too. It makes development and applications faster and it reduces the required bandwidth.

This is how we use the donations:

  • Allow the core team to work on webpack
  • Thank contributors if they invested a large amount of time in contributing
  • Support projects in the ecosystem that are of great value for users
  • Support projects that are voted most (work in progress)
  • Infrastructure cost
  • Fees for money handling

Premium Partners

Other Backers and Sponsors

Before we started using OpenCollective, donations were made anonymously. Now that we have made the switch, we would like to acknowledge these sponsors (and the ones who continue to donate using OpenCollective). If we've missed someone, please send us a PR, and we'll add you to this list.

Gold Sponsors

Become a gold sponsor and get your logo on our README on GitHub with a link to your site.

Silver Sponsors

Become a silver sponsor and get your logo on our README on GitHub with a link to your site.

Bronze Sponsors

Become a bronze sponsor and get your logo on our README on GitHub with a link to your site.

Backers

Become a backer and get your image on our README on GitHub with a link to your site.

Special Thanks to

(In chronological order)

  • @google for Google Web Toolkit (GWT), which aims to compile Java to JavaScript. It features a similar Code Splitting as webpack.
  • @medikoo for modules-webmake, which is a similar project. webpack was born because of the desire for code splitting for modules such as Webmake. Interestingly, the Code Splitting issue is still open (thanks also to @Phoscur for the discussion).
  • @substack for browserify, which is a similar project and source for many ideas.
  • @jrburke for require.js, which is a similar project and source for many ideas.
  • @defunctzombie for the browser-field spec, which makes modules available for node.js, browserify and webpack.
  • @sokra for creating webpack.
  • Every early webpack user, which contributed to webpack by writing issues or PRs. You influenced the direction.
  • All past and current webpack maintainers and collaborators.
  • Everyone who has written a loader for webpack. You are the ecosystem...
  • Everyone not mentioned here but that has also influenced webpack.