4

I am using create-react-app with TypeScript template to manage my React project (yarn create react-app my-app --template typescript)

When I run react-scripts build my code is built into /build folder. How to customize this directory?

I tried to change outDir of compilerOptions in tsconfig.json, but this seems ignored by CRA.

1

2 Answers 2

4

It seems impossible at this moment,

based on the QA: Use custom build output folder when using create-react-app


There are workarounds, however.

For example, you can build then move it

Inside package.json

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

Refer: issue: https://github.com/facebook/create-react-app/issues/1354

There are many other solutions there, find a suitable one would be good.

Sign up to request clarification or add additional context in comments.

Comments

3

You can set BUILD_PATH and do as such on Windows set \"BUILD_PATH=new-folder\" && react-scripts build

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.