Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding the 'src' folder from output during typescript compilation?

When running tsc how do we exclude the src folder (Root containing folder) from output? I have the outDir set to target and instead of target/src/file.ts I would like target/file.ts?

like image 626
Ole Avatar asked Aug 01 '26 13:08

Ole


1 Answers

Your probably looking for the rootDir tsconfig option. Specifically, in your case: rootDir: 'src/', supposing your keeping all source files under ./src/ and your tsconfig.json at the level above src/.

Note however, tsc may silently ignore this setting if your actually importing files that aren't under src/, say for example you import your package.json from top level.

like image 76
spinkus Avatar answered Aug 03 '26 04:08

spinkus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!