我怎样才能Concat的打字稿文件,Angular2例如Rails资产:precompile? [英] How can I concat TypeScript files with Angular2 like Rails assets:precompile?

查看:125
本文介绍了我怎样才能Concat的打字稿文件,Angular2例如Rails资产:precompile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何Concat的多个打字稿与Angular2文件转换成单一的JS文件例如Rails资产:precompile

How can I concat multiple TypeScript with Angular2 files into single JS file like Rails assets:precompile?

例如,在 angular2官方页面的教程你看到四个.TS文件:

For example, in a tutorial of angular2 official page, you see four .ts files:


  • app.component.ts

  • boot.ts

  • hero.ts

  • 英雄detail.component.ts

和当你在看 app.component.ts 文件中,您将看到以下部分:

and when you look at app.component.ts file, you see the following part:

import {Hero} from './hero';
import {HeroDetailComponent} from './hero-detail.component';

在编译所有.TS单独的文件,但我想CONCAT()他们到一个单一的.js文件中,这样会有更少的HTTP请求,它完美。我使用的是一饮而尽,并试图吞掉-CONCAT ,它没有工作。 browserify 没有。​​

It works perfectly when you compile all .ts files separately, but I'd like to concat() them into one single .js file so that there would be less http requests. I'm using gulp, and tried gulp-concat, which didn't work. browserify neither.

会有人帮助吗?
先谢谢了。

Would anyone help? Thanks in advance.

推荐答案

它看起来像打字稿将<一个href=\"https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#option-to-concatenate-amd-and-system-modules-into-a-single-output-file\"相对=nofollow>支持串联多个文件(模块)从1.8版本开始(1.7.5是电流)。也有使用的WebPack 的另一种方式,但我不知道它是如何做到准确

It looks like typescript will support concatenating multiple files(with modules) from version 1.8 onwards(1.7.5 is current). There is also another way using webpack, but I don't know how it is done exactly.

这篇关于我怎样才能Concat的打字稿文件,Angular2例如Rails资产:precompile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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