编辑:有没有一种方法可以优化这段代码?
task.coffee
# Watch pages
gulp.task 'jade', ->
# Watch index
gulp.src('src/jade/index.jade')
.pipe(jade(pretty: true))
.pipe gulp.dest('dist')
# Watch views
gulp.src('src/jade/views/*.jade')
.pipe(jade(pretty: true))
.pipe gulp.dest('dist/views')
# Watch views/products
gulp.src('src/jade/views/products/*.jade')
.pipe(jade(pretty: true))
.pipe gulp.dest('dist/views/products')
gulp.watch 'src/jade/*.jade', ['html']
gulp.task 'html', (callback) ->
runSequence 'jade', callback
return
假设我正在运行gulp任务来处理我的.jade文件,并且我正在开发一个angular应用程序(views/**/*.html),我该如何使我的任务保持简洁,以便更改我的任务来实现这一点?
// gulp.src('src/jade/**/*.jade')
// gulp.dest('dist/path/*.html') so for example 'src/jade/index.jade'
// will be output into 'dist/index.html' and
// 'src/jade/views/products/product.jade' will be
// output into 'dist/views/products/product.html'
task.coffee
# Watch pages
gulp.task 'jade', ->
gulp.src('src/jade/*.jade')
.pipe(jade(pretty: true))
.pipe gulp.dest('dist')
gulp.watch 'src/jade/*.jade', ['html']
gulp.task 'html', (callback) ->
runSequence 'jade', callback
return
task.js
gulp.task('jade', function() {
return gulp.src('src/jade/*.jade').pipe(jade({
pretty: true
})).pipe(gulp.dest('dist'));
});
gulp.watch('src/jade/*.jade', ['html']);
gulp.task('html', function(callback) {
runSequence('jade', callback);
});
**
之前的所有内容都被剥离掉了(即src/jade/
),但**
之后的文件夹结构保留不变。 - Sven Schoenung