如何将整个文件夹及其子文件夹gulp.src,然后基于文件gulp.dest';地点?
编辑:是否有方法清理此代码 咖啡如何将整个文件夹及其子文件夹gulp.src,然后基于文件gulp.dest';地点?,gulp,Gulp,编辑:是否有方法清理此代码 咖啡 # 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 gul
# 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
# 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
假设我正在运行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'
咖啡
# 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
# 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);
});
您的问题的答案已经在您自己的帖子中:
// gulp.src('src/jade/**/*.jade')
在您的jade
任务和watch
中使用此选项应该可以完全完成您想要的:
gulp.task('jade', function() {
return gulp.src('src/jade/**/*.jade')
.pipe(jade({pretty: true}))
.pipe(gulp.dest('dist'));
});
gulp.watch('src/jade/**/*.jade', ['html']);
这将在dist
文件夹中生成如下文件:
src/jade/index.jade -> dist/index.html
src/jade/views/example.jade -> dist/views/example.html
src/jade/views/products/product.jade -> dist/views/products/product.html
...
每个文件是否会自动输出到相应的路径中?gulp.dest('dist')是否只是将'src/path/of/the/*.file'更改为'dist/path/of/the/*.file'?是的,请参阅我编辑的答案。
**
之前的所有内容都会被剥离(即src/jade/
),但**
之后的文件夹结构会保留下来。