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.

Question: How to change output folder for build files.

See original GitHub issue

This is folder’s structure of my project.

project_frontend /
    app/
    package.json

project_backend/
    api/
    static/
    index.html

So I launch npm run build from project_frontend and I need to put build files into project_backend. Also I don’t need to put into there files like “manifest.json”, “asset-manifest.json”. Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

33reactions
gaearoncommented, Jan 17, 2018

In your package.json you have:

  "scripts": {
    "build": "react-scripts build"

You can add another script called postbuild that does something after the build and will be called by npm/Yarn automatically.

  "postbuild": "mv build ../project_backend/"

You could also run a custom script that does more.

  "postbuild": "node postbuild.js"

Hope this helps!

15reactions
thecalvinchancommented, Jun 24, 2018

i don’t think this is a valid solution because it assumes that the build directory is not being used by some other service. For example, i have backend code that compiles to a build directory, then this would also affect those files as well.

True, a proper separation of concerns here would be the right move, making each their own codebase and repository, but would definitely like to see an option to set a build-dir option in react scripts

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the build output directory - Visual Studio (Windows)
To place all solution outputs in a common directory · Click on one project in the solution. · On the Project menu, click...
Read more >
Use custom build output folder when using create-react-app
Change in your package.json the script item into "build": "react-scripts build && mv build webapp" where webapp is your destination folder; ...
Read more >
Refilled, Setting the build output folder of multiple projects with ...
With my ~50 projects set to the same output folder and many of them with the same (nuget) ... So my question again:...
Read more >
How to set output directory for all compiled and linked files in ...
Hello, I'm using CCS v6.1.0 and have been having trouble getting the output directory to change for all of the compiled files.
Read more >
How to change output directory for managed build
Everything is ok for build and debug, but the outputs (.elf file, .bin, etc...) are generated in Release and Debug directory at the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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