2015-09-06 59 views
2

我正在使用Sublime Typescript插件來轉錄Typescript文件。無法將SourceMap(.map)文件移動到Typescript中的單獨文件夾中

項目文件夾

enter image description here

我已經做了所有的設置的示例項目與tsconfig.json的幫助(使用1.5V打字稿)。下面是我tsconfig.json

{ 
    "compilerOptions": { 
     "declaration":false, 
     "mapRoot":"mapFiles", 
     "module": "commonjs", 
     "noImplicitAny": true, 
     "outDir": "js", 
     "preserveConstEnums": true, 
     "removeComments": true, 
     "sourceMap": true, 
     "sourceRoot": "mapFiles", 
     "target":"es3", 
     "watch":true, 
     "rootDir":"" 
    } 

} 

要將所有sourceMap文件移動到其他文件夾(映射文件)的文件夾,而不是在同一個文件夾中的所有文件(.js文件和文件.MAP)保持一致,我已經下面添加到配置tsconfig.json

"mapRoot":"mapFiles", 
"sourceMap": true, 
"sourceRoot": "mapFiles", 

完成構建之後,腳本文件與sourceMappingURL意見一起成功生成。下面是出來的main.ts文件。

var x = "will work"; 
//# sourceMappingURL=E:/type/projects/Examples/ex1/mapFiles/main.js.map 

但main.js.map文件沒有移動相應的文件夾(mapFiles)。它位於生成js文件的相同文件夾中。

Below is my understanding about .maps files: 

1. Map files have the details about the respective .ts files with location of it. 

2. it is used to track down .ts files easily. 

請讓我知道如何在運行時將sourceMap文件移動到其他文件夾。

回答

1

有類似於您的問題here的東西。看看那裏,你一定能夠決定什麼方法符合你的願望。

我沒有看到一個問題,使他們都在同一個文件夾中,而*.js.map*.js甚至不會被推到您的回購,只是.gitignore他們。我使用IntelliScript插件,這已經有助於防止眼睛變幹。 enter image description here

如果有理由將它們分開並且我沒有意識到它,那麼您可以編寫一個將它們分開的任務。因此請在您的tsconfig.json中保留"mapRoot":"mapFiles", "outDir": "js",並在package.json中添加一個腳本來移動它們。

相關問題