Search code examples
reactjsgitcreate-react-app

how to initialize create-react-app in existing github repo


I'm sometimes using create-react-app inside an existing repo that contains some other stuff (or it's just a repo that someone else created and gave me access to). The workflow for that seems a bit weird, especially due to the create-react-app naming restrictions

git clone git@github.com:MY-ORG/MY-REPO.git
cd MYREPO
npx create-react-app my-app
cp my-app/* ./
rm -rf my-app

that seems to be a bit a strange flow and I'm wondering how other people do this more elegantly.


Solution

  • I can't say for certain this will work with all situations, but I find myself needing to create a GitHub repo first for any project. Then I clone it, and change into that directory.

    But instead of running CRA with my-app, I simply run it with a . plus my templates.

    The steps looks something like this:

    git clone git@github.com:MY-ORG/MY-REPO.git
    cd MY-REPO
    npx create-react-app . --template typescript