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

Categories

0 votes
1.1k 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...