Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

typescript - tsconfig.json - Only build ts files from folder

I am currently trying to build my ts files into a single ts files. The issue I'm getting is that my code below isn't doing what I thought it would. I used sourceRoot to attempt to set the only place it could get the source from but that didn't work. I have also tried putting a . infront of the directory but it still pulls from everywhere :(

{
   "compilerOptions": {
       "target": "ES5",
       "noImplicitAny": true,
       "removeComments": true,
       "preserveConstEnums": true,
       "out": "www/js/app.js",
       "sourceMap": true,
       "sourceRoot": "www/app"
   }
}

all files including those not inside of www/app build :(

for now I've moved back to manually specifying the files:

{
    "compilerOptions": {
        "target": "ES5",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "out": "www/js/app.js",
        "sourceMap": true
    },
    "files": [
        "./www/app/app.ts",
        "./www/app/menu/menuController.ts",
        "./www/app/playlists/playlistsController.ts"
    ]
}

is it possible to restrict the source directories to be only www/app?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes,it is possible. Please use rootDir like 'rootDir': 'app', if www is your root dir of your application.

rootDir description from typescript compiler options:

Specifies the root directory of input files.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...