如何使用 xampp/angular2/typescript 强制转译

How to force transpile with xampp/angular2/typescript

今天是第二次,我运行遇到这个问题:偶尔修改模板文件(.html)后,老模板还在用。我尝试了多种方法来解决这个问题:

  1. 在浏览器中刷新页面;
  2. 在浏览器中使用 ctrl+f5 刷新页面;
  3. 甚至重新启动 Apache。

但结果似乎真的不一致,上面的一些时间 none 奏效了。我怀疑这在某种程度上与 t运行spile 的触发方式有关。

我如何才能 g运行tee 在修改模板时触发 t运行spile?

(不确定代码在这种情况下是否重要,但您可以参考 。例如,如果我将占位符更改为下面,则拼写错误的 "first" 不一定出现。)

placeholder="Enter firsttttta name here">

更新:

正如 @basarat 在他的评论中指出的那样,通过将以下内容添加到 httpd.conf 解决了这个问题(我添加了 ts|ts!t运行spiled 到列表中。ts 是typescript 的文件扩展名,而 angular2 似乎使用 ts!t运行spiled 作为 t运行spiled 脚本。)

<filesMatch "\.(html|htm|js|css|ts|ts!transpiled)$">
  FileETag None
  <ifModule mod_headers.c>
     Header unset ETag
     Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
     Header set Pragma "no-cache"
     Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
  </ifModule>
</filesMatch>

refresh the page in browser with ctrl+f5;

理想的解决方案是在开发期间从服务器发送 headers 告诉客户端不要缓存结果:

Cache-Control:no-cache, no-store, must-revalidate
Pragma:no-cache
Expires:0