在 azure git deploy 中包含 TypeScript 文件 [英] Include TypeScript files in azure git deploy

查看:19
本文介绍了在 azure git deploy 中包含 TypeScript 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的自动 git 部署中包含 TypeScript 文件,以便展示我正在构建的框架的代码.但是,每当我部署到 azurewebsites 时,部署都不包含 TypeScript 文件.

I'm trying to include TypeScript files in my automatic git deploy so I can showcase code for a framework I'm building. However, whenever I deploy to azurewebsites the deployments do not include the TypeScript files.

相关网站:http://endgate-samples.azurewebsites.net/Samples/AnimatedSprites/

我的尝试:

  1. 通过将 TypeScript 属性设置为始终复制",将所有 TypeScript 文件复制到输出文件夹.问题是我需要更改对所有文件的引用(不想这样做).

  1. Copy all TypeScript files to output folder by setting TypeScript properties to "Copy Always". Issue with this is that I need to change the references to all the files (do not want to do this).

MSBuild 管道.这适用于文件系统部署,但不适用于 Web 部署... https://github.com/NTaylorMullen/EndGate/blob/master/EndGate/samples/EndGate.Core.JS.Samples/EndGate.Core.JS.Samples.csproj#L896-L909.

MSBuild pipeline. This works for file system deploy but not web deploy... https://github.com/NTaylorMullen/EndGate/blob/master/EndGate/samples/EndGate.Core.JS.Samples/EndGate.Core.JS.Samples.csproj#L896-L909.

手动发布到 FTP 端点(就像一个魅力),但不是自动的.还需要 msbuild 管道 (#2)

Manual publish to FTP endpoint (works like a charm), but not automatic. Also requires the msbuild pipeline (#2)

我做错了什么或者我可以做什么(我没有尝试过)来让我的 TypeScript 文件自动部署?

What am I doing wrong or what can I do (that I haven't tried) to get my TypeScript files deploying automagically?

推荐答案

因此,经过大量工作,结果表明,使用 msbuild 管道部分(#2)它实际上会部署 typescript 文件.我缺少的一件事是添加适当的 mime 类型来处理 typescript 文件.

So after a lot of work it turns out that with the msbuild pipeline piece (#2) it will actually deploy the typescript files. One thing that I was missing was adding the appropriate mime type to handle typescript files.

事实证明,默认情况下 IIS 无法正确提供 TypeScript 文件.

It turns out by default IIS won't serve the TypeScript files correctly.

要添加我所做的自定义 mime 类型:

To add the Custom mime type I did:

<system.webServer>
    <staticContent>
      <remove fileExtension=".ts"/>
      <mimeMap fileExtension=".ts" mimeType="text/plain" />
    </staticContent>
</system.webServer>

在添加 mime 类型之前,我们删除现有的 .ts mime 类型(如果有的话)很重要.如果您部署到已经具有 .ts mime 类型的机器上并且在添加之前没有删除,它几乎会破坏您现有的映射并且将无法提供任何 css、js 文件等.

It's important that we remove the existing .ts mime type (if there is one) prior to adding the mime type. If you deploy onto a machine that has the .ts mime type already and you do not remove prior to adding, it will pretty much destroy your existing mappings and will fail to serve any css, js files etc.

这是一场战斗,但我终于成功了,希望这对未来的其他人有所帮助!

This has been a battle but I finally got it working, hope this helps somebody else in the future!

这篇关于在 azure git deploy 中包含 TypeScript 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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