所以我想以下将与吞咽工作。我没有尝试过Angular 2的设置,但我想这个主题的一些变化会得到结果。
您将需要以下一饮而尽插件:
gulp-typescript
gulp-concat
gulp-uglify
gulp-rename
或者你可以抓住gulp-load-plugins
,所有的这些都可以从那里。我将演示简单的方法。
你需要将类似下面的设置:
const tsConfig = require('./path/to/tsConfig.json').compilerOptions;
const plugins = require('gulp-load-plugins')();
const appFiles = ['{{THE FILES YOU WANT TO COMPILE}}'];
const buildDir = './path/to/desired/build/directory';
然后将下面的管道应达到预期的效果:
gulp.src(appFiles)
.pipe(plugins.typescript(tsConfig))
.pipe(plugins.concat('app.js'))
.pipe(plugins.uglify())
.pipe(plugins.rename('app.min.js'))
.pipe(gulp.dest(buildDir));
我知道我的情况,我需要包括一个gulp-ng-annotate
步uglifying之前,所以我不知道是否类似的东西将不得不为Angular 2做。但总的想法是gulp-typescript
以某种方式通过你的tsconfig.json
和gulp-concat
为创造一个输出文件。
希望有所帮助。让我知道由此产生的问题。
你是否在使用SystemJS作为模块加载器?如果是这样的话[SystemJS Builder](https://github.com/systemjs/builder)适合捆绑和缩小一切。 – JayChase