Have you even been in a situation where your project has grown out of bounds and CRA (webpack internally) hasn’t been able to scale nicely with the size of your project?
Well, I have, and that led me to start searching for other options of building a react project than plain old CRA.
There are few options which present itself for this solution, but I wanted something easy and one that would scale when my project becomes large.
1. Ejecting and getting your hands dirty with Webpack
Playing with Webpack and setting it up from scratch was never easy and its one of the reasons why the React team created CRA in the first place. Therefore, this was one was out of running from the beginning.
Rollup makes sure that all your code is put in the same place and evaluates in one go, resulting in leaner, simpler code that starts up faster. But Rollup, has the following demerits:
- No HMR (Hot
- Handicaps on converting specific code to ES2015.
Also, Rollup was more suitable for libraries and not for web apps which is what I was looking for.
Parcel is a zero config web app builder which was like a god send. It checked all the features which I was looking for:
- Zero config
- Default react support
- Typescript support
- Parallelism and Caching
The best part of parcel is that you can set the entry file to be a HTML file and parcel figures out all the dependencies within the HTML file and generates the necessary build.
This is a stark difference from the other two, where it just bundles JS and CSS and doesn’t take into account the HTML file.
I’ve now created a template project which includes all the good practices in a new project and it builds extremely fast using parcel 2.
I just changed some text in the App.tsx file and the new build was done in under 0.6 seconds.
Open the link below and click on “Use this template” to quickly get started with a new react app using parcel.
You can't perform that action at this time. You signed in with another tab or window. You signed out in another tab or…
It includes the following:
If you do like the project, please comment here or star the project. It helps me to continue being motivated to bring such articles and projects. Thanks. 😸 😄