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:
- Install dependencies:
react,react-dom,webpack,webpack-cli,babel-loader,@babel/preset-react - Create
webpack.config.js: Tell Webpack where your entry file is, where to output bundles, and how to handle different file types - Configure Babel: Set up
.babelrcto transform JSX into regular JavaScript - Set up loaders: Define rules for processing
.jsxfiles, CSS, images, etc. - Add a dev server: Configure
webpack-dev-serverfor local development (no HMR by default!) - 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.