Is it possible to compile Typescript files locally but not on the build server?

牧云@^-^@ 提交于 2019-12-23 22:13:46

问题


I've added Typescript to my build process, but I'm getting the Write to file failed error because the destination js file is Read Only, and this is because I'm including the emitted js file in TFS.

I know I could remove the js file from TFS and always generate on the fly, but I don't want to do that because I want to include them in the project and the deployment to the build server will fail if I do that with files that aren't in TFS.

I could use a pre-build step to remove the Read Only attributes but that seems kludgy.

What I really want is to include the js files and have the precompiled on build, but only on my local dev machine and not on the build server. I would even be happy with compiling them on save and not on build. But I can't find a way to accomplish either of these.


回答1:


I know you stated that you want to include them in your project which is why you want to include the js files in version control (TFS), but IMO that is not the approach to take, for the same reason you do not check in your dll's.

In the case of TypeScript the *.ts files are your source code and *.js files are your compiled output which are easily reproduced by your build process whether that be MsBuild or gulp/grunt.

If you are using the bundling/minification libraries then you need not worry as the files included in them are based upon the file structure and not upon the the project structure. You can simply include the necessary files/directories within the necessary bundle(s).

I know this may not be the answer that you were looking for, but I feel like it has a place as a potential solution in regards to how to handle the output of js files from ts source code.



来源:https://stackoverflow.com/questions/29495592/is-it-possible-to-compile-typescript-files-locally-but-not-on-the-build-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!