In a previous blog post I wrote about a bash script I wrote that would basically run create-react-app (CRA) and then it would delete the src folder and the package.json and copy over the src folder and package.json from a boilerplate I built off of the default CRA into the new project and then install the new dependencies, open the project in VS Code and start the server.
Since then, I have learned how to build my own CRA template! You can read about that here. Now that I can just install my own template it has cut down a good chunk of code, so I thought I'd share my bash script now that it has lost a few extra pounds.
So now my bash script looks something like this:
#!/bin/bash
# run create react app
yarn create react-app $1 --template bushido
# Push into new project directory
pushd $1
# Open new project in VS Code
code .
# Runs new server
yarn start
And just like that, all I need to do is, create <project-name>
, and I have a script that will spin up a my custom react template with redux and router and other things already set up, open it in VS Code and start the server all in just one easy command. Thanks for reading! If you want to learn the basics on how to create a bash script, check out this blog.