Skip to content

Create React App inside a non-empty folder #7802

Open
@erdemkeren

Description

@erdemkeren

I use create-react-app to create a react app inside an existing backend project which will serve the react application. And I have to run the eject command to:

  • change the target directory
  • change the build logic and directories
  • add .less support with some extra configuration
    and so on...

To automate this process, I took a fork from react-scripts and I defined my folder structure. A

My final file system hierarchy should be something like:

- project directory
    - foo
    - bar
    - baz
    - resources
        - react-app
            - index.js
    - package.json 
    - qux.php

So I edited the template folder to match these requirements and published the scripts to give a try.

npx create-react-app . --scripts-version my-react-scripts

And as you guessed, I got

The directory . contains files that could conflict: Backend FSH.

However:

  • I need my package.json to be located in the project root directory.
  • My scripts will create a new directory called react-app inside the existing resources folder. And react-app will live inside this directory. I don't expect an override.
  • My build is customized and will use my webpack plugin to generate the built files. I don't expect an unexpected override here as well.

Describe the solution you'd like

  • Since I know what I do, I want to have some way to run create-react-app in an existing folder with some files.

Maybe by setting a constant from my scripts or using an option after npx create-react-app call.

Describe alternatives you've considered

I considered to update create-react-app to support it as well but that doesn't make sense since it would be almost impossible to follow up the updates and upgrades later.

Additional context

#334
#2776

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions