Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #7802
Closed
Open
Issue created Oct 10, 2019 by Administrator@rootContributor

Create React App inside a non-empty folder

Created by: 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

https://github.com/facebook/create-react-app/issues/334 https://github.com/facebook/create-react-app/issues/2776

Assignee
Assign to
Time tracking