最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Excluding the 'src' folder from output during typescript compilation? - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question asked Jul 12, 2018 at 22:34 OleOle 47.6k70 gold badges238 silver badges445 bronze badges 13
  • Do you have all your code in the src folder? – Simeon Smith Commented Jul 12, 2018 at 22:37
  • I'm assuming this question is related to your last one? – Patrick Roberts Commented Jul 12, 2018 at 22:37
  • @PatrickRoberts it's related in the sense that I'm pursuing creating a clean dist or target directory to publish from...Would be a lot easier if there was a base package.json property though ... :) – Ole Commented Jul 12, 2018 at 22:39
  • 1 How about using the "include" option in your tsconfig? So something like {"pilerOptions": { ... }, "include": [ "./src/" ]}? – CRice Commented Jul 12, 2018 at 23:01
  • 1 You're going to want a different tsc mand to pile your tests. You can't do both at the same time and have the src not pile to the same folder. You can chain the mands though. – Simeon Smith Commented Jul 13, 2018 at 2:53
 |  Show 8 more ments

1 Answer 1

Reset to default 6

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.

发布评论

评论列表(0)

  1. 暂无评论