Course contentsShow
← React
Lesson 54 of 2,3962. Setup and Modern ToolingFree lesson

Webpack from Scratch

Manual React setup with Webpack and Babel: understanding what Vite and CRA abstract away.

Webpack from Scratch

What you'll learn: How to manually configure React with Webpack and Babel to understand what modern tools like Vite hide from you.

The Manual Setup Journey

When you use Vite, it handles all the complex build tooling automatically. But understanding what happens under the hood helps you troubleshoot issues and appreciate why modern tools exist.

Webpack is a module bundler—it takes all your separate JavaScript files, CSS, images, and other assets and combines them into optimized bundles that browsers can load efficiently.

Babel is a transpiler—it converts modern JavaScript (including JSX) into older JavaScript that all browsers understand.

What You'd Configure Manually

Without Vite or Create React App, you'd need to:

  1. Install dependencies: react, react-dom, webpack, webpack-cli, babel-loader, @babel/preset-react
  2. Create webpack.config.js: Tell Webpack where your entry file is, where to output bundles, and how to handle different file types
  3. Configure Babel: Set up .babelrc to transform JSX into regular JavaScript
  4. Set up loaders: Define rules for processing .jsx files, CSS, images, etc.
  5. Add a dev server: Configure webpack-dev-server for local development (no HMR by default!)
  6. Production optimization: Manually configure minification, code splitting, and bundling strategies

The Abstraction Analogy

Think of Vite/CRA as an automatic car and Webpack-from-scratch as a manual transmission. The automatic handles gear shifts (build config) for you. The manual gives you complete control but requires you to manage every shift yourself.

Key Takeaway: Manual Webpack setup reveals the complexity that Vite abstracts—module bundling, transpilation, dev servers, and optimization all require explicit configuration, which is why modern tools like Vite have become the standard.