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
  • !4039

Configurable build output directory

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/oliverlaz/build-dir into next Feb 18, 2018
  • Overview 3
  • Commits 1
  • Pipelines 0
  • Changes 2

Created by: oliverlaz

This pull request enables build output directory to be configured via special environment variable. I think this change will come handy in some special environments where build folder can't be deployed directly.

Default output:

$ yarn build
yarn run v1.3.2
$ cd packages/react-scripts && node bin/react-scripts.js build
Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  35.56 KB  build/static/js/main.c76fe2d2.js
  526 B     build/static/css/main.de8ab87f.css

The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:

  "homepage" : "http://myname.github.io/myapp",

The ../../build folder is ready to be deployed.

Output with build directory override:

$ BUILD_DIR=target/generated-resources/app yarn build
yarn run v1.3.2
$ cd packages/react-scripts && node bin/react-scripts.js build
Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  35.56 KB  app/static/js/main.c76fe2d2.js
  526 B     app/static/css/main.de8ab87f.css

The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:

  "homepage" : "http://myname.github.io/myapp",

The ../../target/generated-resources/app folder is ready to be deployed.

Sidenote: In my case, I'm bundling a React application as part of a larger Java application. For that purpose, bundle resources should be packaged as a .jar package and included as a Maven dependency in the parent project. A precondition for achieving this is to put the bundles in the Maven's generated-resources directory. In order to fulfill this precondition, either some additional build steps should be added or the app should be ejected. I want to avoid ejection as the default CRA configuration suits fine.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/oliverlaz/build-dir