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

Question: How to change output folder for build files. #3824

Closed
pasichnyk opened this issue Jan 17, 2018 · 5 comments · Fixed by #8986
Closed

Question: How to change output folder for build files. #3824

pasichnyk opened this issue Jan 17, 2018 · 5 comments · Fixed by #8986

Comments

@pasichnyk
Copy link

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.

@gaearon
Copy link
Contributor

gaearon commented 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!

@thecalvinchan
Copy link

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

@sairathb
Copy link

I found a way to get it to work. I was facing the same issue of moving my react build to ../public folder, since I am writing a test application and using node back end. You can run the npm run eject to get all the webpack files. then change the ./config/path.js file to update appBuild: resolveApp('../public'),

Hope that helps

@pavelhamrik
Copy link

@sairathb I wouldn't eject just for this, losing the ability to update.

@nsoufian
Copy link

I absolutely agree with you @pasichnyk , I have the same issues I always ejecting my react.js projects for changing the build path or adding one or two plugins to my webpack and I lose the ability to update my scripts.
I hope that react team @gaearon takes into consideration this problem and try to find
a good solution for us" React.js users" to add configurations to env or webpack without ejecting and losing the ability of updates, it's can help us a lot, for example creating new open source project that depends on create-react-app.

tanks you react team for hooks :D

@lock lock bot locked and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants