2015-09-06 44 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中添加一个脚本来移动它们。

相关问题