React boilerplate with Parcel bundler.
The Parcel React Boilerplate is a simple React boilerplate that uses Parcel bundler, linter, prettier, and other tools to create new React apps quickly. This guide focuses on creating a smaller and simpler boilerplate than the Create React App (CRA) version with Parcel. It is recommended for people who are new to React and want to understand the problems that CRA solves before using it. Parcel is a fast bundler that does not require a config file and provides features like tree shaking, caching, code splitting, and live reload out of the box.
yarn init -y (or any package manager of your choice)..babelrc file in the project root folder and add the following content:{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
package.json file:"scripts": {
"start": "parcel src/index.html",
"build": "parcel build src/index.html"
}
src/index.html to the route of your main HTML file.index.html file, import the index.js file and add a <div> element with the id root where the React content will be added.index.js file, add the basic React code.yarn add -D prop-types.yarn add -D autoprefixer postcss..postcssrc file in the project root folder and add the following content:{
"plugins": {
"autoprefixer": {}
}
}
index.scss file and import it in the index.js file.The Parcel React Boilerplate provides a simplified and lightweight setup for creating React apps using Parcel bundler. It focuses on offering the essential features needed for React development without the additional complexity of tools like Create React App. The guide explains the installation process and highlights the benefits of using Parcel, such as its fast build times, tree shaking, code splitting, and live reload capabilities. Additional extras like prop validation with PropTypes and CSS autoprefixing with autoprefixer can be easily added for convenience during development.