Suppose that my project is like this:
├── dist
├── src
│ ├── greeter.ts
│ ├── index.html
│ └── test.txt
└── tsconfig.json
Only greeter.ts
need to be complied to dir dist
, but how about other files? How to copy other files to dir dist
?
here is my gulpfile.js
:
gulp.task('ts',cb=>{
return gulp.src('src/**/*.ts')
.pipe(sourcemaps.init())
.pipe(tsProject())
.js
.pipe(babel({
presets: ['env']
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
Create a another task to copy other files and add its dependency on other task
gulp.task('copyFile', function () {
return gulp.src([
'src/**/*', //Include All files
'!src/**/*.ts' //It will exclude typescript files
]).pipe(gulp.dest('dist'));
});
gulp.task('ts', ['copyFile'], cb => {
//Your existing code
});