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
  • Merge requests
  • !8986

Add support for new BUILD_PATH advanced configuration variable

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/ajhyndman/build-path-variable into master May 10, 2020
  • Overview 20
  • Commits 2
  • Pipelines 0
  • Changes 2

Created by: ajhyndman

Summary

Adds support for a new environment variable, BUILD_PATH, which overrides the create-react-app output directory.

Fixes #378 Fixes #778 (closed) Fixes #1354 (closed) Fixes #3824 (closed) Fixes #3973 (closed) Fixes #6211 (closed) Relates to #7802 Fixes #8600 (closed)

Rationale

First, I know, this is a hot button issue. I have been following create-react-app for years now, and I understand and support the objective of providing a configuration-free setup experience for new React projects. However, I hope you'll allow me a few paragraphs to make an argument for this change.

I think there are several qualities about build path configuration that make it a good candidate as an addition to create-react-app's set of "advanced configuration" environment variables:

  • It's trivial to support. Including documentation, this whole diff is less than 10 lines of code.
  • CRA is very hands-off about what you do with build output, so this change is unlikely to add a maintenance burden.
  • It still generates issues and support requests. image
  • There are real compatibility issues that existing recommendations can't resolve.
    • The mv command is not cross-platform compatible
    • The 'build' path can conflict with other tooling
    • Symlink-based build systems are hard to support
  • A large number of users describe or recommend ejecting solely for the purpose of changing output path.

In summary, I think that a customisable output path is: cheap to support, won't add to maintenance burden, reduces ongoing support work, and allows significantly more projects to avoid ejecting and benefit from future CRA updates. Together, I think these qualities make a new BUILD_PATH environment variable a good candidate for support.

Verification

To verify this change works, I followed the guide in CONTRIBUTING.md and bootstrapped a project locally.

$ cd create-react-app 
$ yarn
$ yarn create-react-app my-app

In that project, I verified the following configuration cases:

  1. With no configuration, files are still output to /build:

image

  1. With the unprefixed folder name 'dist', files are output to /dist:

image

image

  1. With a parent-relative path specified, files are output to the correct location:

image

image

In the third case, I also verified running yarn build multiple times correctly cleans up files before outputting a new build.


Thank you to the create-react-app team being such exemplary members of the React and open source communities, and I appreciate you considering my pull request.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/ajhyndman/build-path-variable