Minimal React 18 starter template powered by Webpack 5 and Babel, with dev server, source maps, and static asset handling for modern single-page applications.
- Node.js 18 or later
- npm for installing dependencies (React and ReactDOM are already listed in
package.jsonand are installed vianpm install).
This template uses the React 18 createRoot API from react-dom/client.
- React 18 and ReactDOM
- Webpack 5 with asset modules for images
- Babel with
@babel/preset-envand@babel/preset-react(automatic runtime) - Shared browser targets via
.browserslistrc - Development server on port 3000 (supports CSS hot reload; JavaScript changes trigger a full page reload unless React Refresh or module
accepthandlers are added) - Source maps (
eval-source-mapin development,source-mapin production)- Public folder handling (favicon, logo, and other static files)
- Minimal global CSS example
- Demonstrates both public-path assets (e.g.,
/logo.svg) and imported assets processed by Webpack asset modules
-
Install dependencies:
npm install
-
Start the development server:
npm start
-
Open http://localhost:3000 in your browser.
To build for production:
npm run buildThe production files will be generated in the dist folder.
npm start– Starts Webpack Dev Server in development mode with fast CSS hot reloading andeval-source-map; JavaScript edits currently reload the page.npm run build– Builds the project in production mode, outputting optimized bundles and source maps to thedistfolder.
public/
index.html # HTML template used by HtmlWebpackPlugin
favicon.svg # Text-based favicon for the browser tab
logo.svg # Example logo used by the demo App
src/
App.js # Root React component
App.css # Sample global styles
index.js # Application entry; mounts React into #root
.babelrc # Babel configuration
.browserslistrc # Browser support matrix
webpack.config.js # Webpack configuration (dev + prod)
package.json # Scripts, dependencies, metadata
.gitignore # Files and folders ignored by Git
- Update
package.jsonmetadata:name,description,author, andlicense(if needed). - Update the HTML title and assets in
public/index.html, and replacefavicon.svgandlogo.svg. - Customize the root component by replacing the contents of
src/App.jswith your own UI. - (Optional) Change the dev server port in
webpack.config.jsunderdevServer.port.
- Uses
@babel/preset-envwithout inline targets; instead, it reads from.browserslistrc. - Uses
@babel/preset-reactwithruntime: "automatic"so you do not need to import React in every JSX file.
.browserslistrc:
> 0.25%
not dead
This configuration defines which browsers are supported and is used by Babel and Webpack.
entry: "./src/index.js"– Single entry point for the application.output.filename: "bundle.[contenthash].js"– Uses a content hash for better caching.- JavaScript/JSX rule with
babel-loader– Transpiles application code based on Babel configuration. - CSS rule with
style-loaderandcss-loader– Enables importing CSS files from JavaScript. - Image rule with
type: "asset/resource"– Handles imported images fromsrc, emitting them todistand returning their URLs. HtmlWebpackPlugin+public/index.html– Uses a template HTML file and injects the final bundle.CopyWebpackPlugin– Copies all assets frompublicintodist(exceptindex.html).devServerwithopen,hot, andhistoryApiFallback– Provides a comfortable SPA development environment; without React Refresh ormodule.hot.accept, JavaScript edits trigger full reloads.
- You can reference static assets from
public/with absolute paths such as/logo.svg. These files are copied as-is todistbycopy-webpack-plugin. - The template ships text-based assets (like
.svg) by default to avoid binary files in version control;.icofiles are ignored via.gitignore. - Alternatively, import assets from
src/(for example,import logo from "./logo.svg";). Webpack'sasset/resourcerule emits the file todistand returns a URL that you can use in JSX.
- In development,
eval-source-mapprovides quick rebuilds with line-accurate stack traces. - In production,
source-mapcreates external maps so errors can be traced back to original source without bloating the main bundle.
- Use the repository as a GitHub template or clone it, remove
.git, and reinitialize for a new project. - Update project metadata, branding assets, and entry component content per project.
- When tooling versions evolve, test upgrades in this template first before rolling them out to new projects.
This template is intentionally minimal. Add libraries such as React Router, state management, testing tools, and styling frameworks per project as needed.
Periodically:
- Run
npm outdatedto see available updates. - Run
npm auditto check for security issues. - Update and test core tooling dependencies (React, Webpack, Babel) in this template to keep it current for future projects.