3

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.

Baterka
  • 3,075
  • 5
  • 31
  • 60
  • Does this answer your question? [Use custom build output folder when using create-react-app](https://stackoverflow.com/questions/41495658/use-custom-build-output-folder-when-using-create-react-app) – MiguelSlv May 04 '22 at 14:39

2 Answers2

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.

keikai
  • 14,085
  • 9
  • 49
  • 68
1

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

Izzy
  • 400
  • 3
  • 9