Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new BUILD_PATH advanced configuration variable #8986

Merged
merged 2 commits into from
Feb 3, 2021

Conversation

ajhyndman
Copy link
Contributor

@ajhyndman ajhyndman commented May 10, 2020

Summary

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

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

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:

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.

@ajhyndman ajhyndman changed the title Build path variable Add support for new BUILD_PATH advanced configuration variable May 11, 2020
@ajhyndman ajhyndman changed the title Add support for new BUILD_PATH advanced configuration variable Add support for new BUILD_PATH advanced configuration variable May 11, 2020
@stale
Copy link

stale bot commented Jun 10, 2020

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jun 10, 2020
@ajhyndman
Copy link
Contributor Author

Bump. I'd love to get some feedback on this.

@stale stale bot removed the stale label Jun 10, 2020
@dmaslov
Copy link

dmaslov commented Jun 15, 2020

Merge this one pls

@JamesXNelson
Copy link

I really need this; I am the buildmaster of a project which assembles java, python, javascript, groovy and C#. All the other languages took me less than a day to make a perfect overlayfs + symlink build cache. javascript has been four days and counting, and I still don't have a solution (can't move build/ location, can't symlink things into place, can't use mount --bind.... it's a real mess). Please, please... conventions are not really conventions unless they are configurable. convention: a way in which something is usually done. If it can't be changed, it's not a convention, it's hard-coded, unconfigurable and frankly a massive PITA to try to support.

@Niesyto
Copy link

Niesyto commented Jul 23, 2020

I'd love it

@stale
Copy link

stale bot commented Aug 22, 2020

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Aug 22, 2020
@ajhyndman
Copy link
Contributor Author

Bump. I'd still love to get some feedback on this.

@stale stale bot removed the stale label Aug 23, 2020
@amyrlam amyrlam removed their request for review August 24, 2020 05:39
@AlliterativeAlice
Copy link

Want to give my vote of support to this too. Would be much more convenient than having to use pre/post-build scripts to shuffle folders around when I have other software in the project using the "build" folder.

Copy link

@Ishaan28malik Ishaan28malik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stale
Copy link

stale bot commented Oct 11, 2020

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Oct 11, 2020
@n3ps
Copy link

n3ps commented Oct 13, 2020

Bump. A lot of people have been waiting on this one.

@goldhand
Copy link
Contributor

As mentioned in #3824 (comment) you are assuming that the ./build directory isn't used by another build tool (which is every package where I where I work). This would be REALLY nice to have :(

@drkstr101
Copy link

This is incredibly annoying. Now I need to filter out all the Gradle build artifacts that go in this folder, or override project conventions for this one little piece that used create-react-app. I suppose the proper solution is to eject, but who has time for all that?

This was referenced Mar 12, 2021
blackarctic added a commit to blackarctic/create-react-app that referenced this pull request Apr 29, 2021
* Fix noFallthroughCasesInSwitch/jsx object is not extensible (facebook#9921)

Co-authored-by: Konstantin Simeonov <kon.simeonov@protonmail.com>

* Add logo license to README

* Remove trailing space in reportWebVitals.ts (facebook#10040)

* docs: add React Testing Library as a library requiring jsdom (facebook#10052)

Co-authored-by: Ian Schmitz <ianschmitz@gmail.com>

* Increase Workbox's maximumFileSizeToCacheInBytes (facebook#10048)

* Create FUNDING.yml

* replace inquirer with prompts (facebook#10083)

- remove `react-dev-utils/inquirer` public import

* Prepare 4.0.1 release

* Prepare 4.0.1 release

* Publish

 - cra-template-typescript@1.1.1
 - cra-template@1.1.1
 - create-react-app@4.0.1
 - react-dev-utils@11.0.1
 - react-scripts@4.0.1

* chore: bump web-vital dependency version (facebook#10143)

* chore: bump typescript version (facebook#10141)

Co-authored-by: Ian Schmitz <ianschmitz@gmail.com>

* Add TypeScript 4.x as peerDependency to react-scripts(facebook#9964)

* remove chalk from formatWebpackMessages (facebook#10198)

* Upgrade @svgr/webpack to fix build error (facebook#10213)

Co-authored-by: Ian Schmitz <ianschmitz@gmail.com>

* Improve vendor chunk names in development (facebook#9569)

* Update postcss packages (facebook#10003)

Co-authored-by: Ian Schmitz <ianschmitz@gmail.com>

* Recovered some integration tests (facebook#10091)

* Upgrade sass-loader (facebook#9988)

* Move ESLint cache file into node_modules (facebook#9977)

Co-authored-by: Ian Schmitz <ianschmitz@gmail.com>

* Revert "Update postcss packages" (facebook#10216)

This reverts commit 580ed5d.

* Remove references to Node 8 (facebook#10214)

* fix(react-scripts): add missing peer dependency react and update react-refresh-webpack-plugin (facebook#9872)

* Update using-the-public-folder.md (facebook#10314)

Some library --> Some libraries

* docs: add missing override options for Jest config (facebook#9473)

* Fix CI tests (facebook#10217)

* appTsConfig immutability handling by immer (facebook#10027)

Co-authored-by: mad-jose <joset@yeswearemad.com>

* Add support for new BUILD_PATH advanced configuration variable (facebook#8986)

* Add opt-out for eslint-webpack-plugin (facebook#10170)

* Prepare 4.0.2 release

* Publish

 - cra-template-typescript@1.1.2
 - cra-template@1.1.2
 - create-react-app@4.0.2
 - react-dev-utils@11.0.2
 - react-error-overlay@6.0.9
 - react-scripts@4.0.2

* tests: update test case to match the description (facebook#10384)

* Bump webpack-dev-server 3.11.0 -> 3.11.1 (facebook#10312)

Resolves facebook#10084 security vulnerability in websocket-driver library version 0.5.6, imported transitively by sockjs

* Upgrade eslint-webpack-plugin to fix opt-out flag (facebook#10590)

* update immer to 8.0.1 to address vulnerability (facebook#10412)

Resolves facebook#10411

Bumps immer version to 8.0.1 to address the prototype pollution
vulnerability with the current 7.0.9 version.

* Prepare 4.0.3 release

* Update CHANGELOG

* Publish

 - create-react-app@4.0.3
 - react-dev-utils@11.0.3
 - react-scripts@4.0.3

Co-authored-by: Ryota Murakami <dojce1048@gmail.com>
Co-authored-by: Konstantin Simeonov <kon.simeonov@protonmail.com>
Co-authored-by: Ian Sutherland <ian@iansutherland.ca>
Co-authored-by: sho90 <aznecosann@gmail.com>
Co-authored-by: Anyul Rivas <anyulled@gmail.com>
Co-authored-by: Ian Schmitz <ianschmitz@gmail.com>
Co-authored-by: Jeffrey Posnick <jeffy@google.com>
Co-authored-by: Evan Bacon <baconbrix@gmail.com>
Co-authored-by: Sahil Purav <sahil5684@gmail.com>
Co-authored-by: Hakjoon Sim <trainto@gmail.com>
Co-authored-by: Chris Shepherd <chris@chrisshepherd.me>
Co-authored-by: Jason Williams <936006+jasonwilliams@users.noreply.github.com>
Co-authored-by: Jabran Rafique⚡️ <jabranr@users.noreply.github.com>
Co-authored-by: John Ruble <johnruble@gmail.com>
Co-authored-by: Morten N.O. Nørgaard Henriksen <morten.n.o.henriksen@icloud.com>
Co-authored-by: Sergey Makarov <serega.s.makar@gmail.com>
Co-authored-by: EhsanKhaki <ehsankhfr@gmail.com>
Co-authored-by: Kristoffer K <merceyz@users.noreply.github.com>
Co-authored-by: Aviv Hadar <Avivhdr@gmail.com>
Co-authored-by: Tobias Büschel <13087421+tobiasbueschel@users.noreply.github.com>
Co-authored-by: mad-jose <44253495+josezone@users.noreply.github.com>
Co-authored-by: mad-jose <joset@yeswearemad.com>
Co-authored-by: Andrew Hyndman <ajhyndman@hotmail.com>
Co-authored-by: Brody McKee <mrmckeb@users.noreply.github.com>
Co-authored-by: James George <jamesgeorge998001@gmail.com>
Co-authored-by: Dion Woolley <woolley.dion@gmail.com>
Co-authored-by: Walker Clem <51654951+wclem4@users.noreply.github.com>
wombleton pushed a commit to AurorNZ/create-react-app that referenced this pull request Jun 1, 2021
abhiisheek pushed a commit to abhiisheek/create-react-app that referenced this pull request May 19, 2023
abhiisheek pushed a commit to abhiisheek/create-react-app that referenced this pull request May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet