question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Customize build folder

See original GitHub issue

On a project I’m currently working on, we’re using a file called BUILD that specifies build instructions for our microservices.

and due to Mac OS Sierra, case insensitivity is an issue, so being able to do something like

react-scripts build --path dist would be ideal in the package.json

is this possible currently?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:49
  • Comments:32 (11 by maintainers)

github_iconTop GitHub Comments

149reactions
gaearoncommented, May 8, 2017

You can do this with something like:

  "build": "react-scripts build && mv build docs"

in scripts in your package.json.

I think this is a good enough workaround for now, so I’ll close this request.

16reactions
gaearoncommented, Jun 27, 2017

You can add

  "postbuild": "node my-script.js"

to scripts in package.json and then move files anywhere in that script. For example it could copy everything in build/* and move those files to ../my-site/public/htdocs/.

but then all the URLs to JS and CSS files would be wrong, since they’re not pointing to the static folder.

If you want to serve from /static, you can set homepage in package.json to http://mywebsite.com/static. Then it will hardcode /static into the paths in index.html and between the bundles.

Additionally, how does one inject initial data into the CRA HTML file

Generally we recommend this:

https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#generating-dynamic-meta-tags-on-the-server

https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#injecting-data-from-the-server-into-the-page

CRA output is just a static file, so any strategy that would work with a static file would work for us too. We don’t support any particular templating syntax but you can come up with your own interpolation that’s completely replaced on server side.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use custom build output folder when using create-react-app
By default, Create React App will output compiled assets to a /build directory adjacent to /src . You may use this variable to...
Read more >
Setting a custom build directory - next.config.js
Setting a custom build directory. You can specify a name to use for a custom build directory to use instead of .next ....
Read more >
Deployment | Create React App
Deployment. npm run build creates a build directory with a production build of your app. Set up your favorite HTTP server so that...
Read more >
Change the build output directory - Visual Studio (Windows)
To change the build output directory using the current .NET Project Designer ... Find the Base output path for C#, and type in...
Read more >
How set the setting of a custom build directory in nextjs?
Nextjs, by default, create the .next build folder and nextjs also, use .next folder with build command. If you change the .next build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found