是否可以在本地而不是在构建服务器上编译Typescript文件? [英] Is it possible to compile Typescript files locally but not on the build server?

查看:163
本文介绍了是否可以在本地而不是在构建服务器上编译Typescript文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Typescript添加到构建过程中,但由于目标js文件为只读,并且由于在TFS中包含了发出的js文件,所以出现了Write to file failed错误.

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.

我知道我可以从TFS中删除js文件并始终在运行时生成,但是我不想这样做,因为我想将它们包括在项目中,并且如果这样做,到构建服务器的部署将失败包含不在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.

我真正想要的是包含js文件,并在构建时进行预编译,但仅在本地开发计算机上,而不在构建服务器上.我什至乐于在保存时编译它们,而在构建时编译它们.但是我找不到一种方法来实现这两个目标.

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.

推荐答案

我知道您说过要在项目中包含它们,这就是为什么要将js文件包含在版本控制(TFS)中的原因,但是IMO不是采取的方法,出于同样的原因,您不签入dll.

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.

对于TypeScript,*.ts文件是您的源代码,*.js文件是已编译的输出,无论是MsBuild还是gulp/grunt,它们都可以在构建过程中轻松复制.

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).

我知道这可能不是您要找的答案,但是我觉得它有可能作为解决ts源代码中js文件输出的潜在解决方案.

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.

这篇关于是否可以在本地而不是在构建服务器上编译Typescript文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆