Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change outputDir (/build) of TypeScript code in create-react-app

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.

like image 361
Baterka Avatar asked Oct 19 '25 18:10

Baterka


2 Answers

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.

like image 190
keikai Avatar answered Oct 22 '25 08:10

keikai


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

like image 25
Izzy Avatar answered Oct 22 '25 06:10

Izzy