2017-05-03 83 views
2

背景

後,我編我的Angular2項目我的打字稿文件,我將有以下目錄結構(簡體):包括所有.d.ts,但不包括在水珠的.ts爲gulp.src

├── app 
│ └── app.module.d.ts 
│ └── app.module.js 
│ └── app.module.ts 
│ └── index.d.ts 
│ └── index.js 
│ └── index.ts 
│ └── sample.component.d.ts 
│ └── sample.component.js 
│ └── sample.component.ts 
│ └── sample.component.html 
│ └── sample.component.css 

問題

使用[email protected]gulp.src(),我怎麼可以創建一個水珠陣列,其中將包括所有的app文件夾下的文件,但忽略了.ts文件對應於其.d.ts文件?

回答

1

在你的情況下,最簡單的方法是明確你想包括什麼。

工作例如:

var gulp = require('gulp'); 

gulp.task('default', function() { 
    gulp.src('app/**/*.*(js|html|css|d.ts)').pipe(gulp.dest('./out')); 
}); 

結果:

$ tree out 
out 
├── app.module.d.ts 
├── app.module.js 
├── index.d.ts 
├── index.js 
├── sample.component.css 
├── sample.component.d.ts 
├── sample.component.html 
└── sample.component.js 

0 directories, 8 files 

看到這裏就一飲而盡水珠選項的文檔: https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulpsrcglobs-options

其固有使用node-gulp模式,記錄在這裏: https://github.com/isaacs/node-glob

+0

這並不能解決我的問題,因爲我不想忽略任何以'.d.ts'結尾的文件。 – mercador

+0

我誤解了需求並更新了我的回答以反映。 –

+0

非常完美,謝謝! – mercador