Gulp 在根目录中查看所有较少的文件
查看根gulp项目目录中的所有less文件,然后只编译保存的less文件。我无法通过第一部分 当我在项目目录中运行$gulp watch时,它会挂起。开始执行任务,但从未完成Gulp 在根目录中查看所有较少的文件,gulp,gulp-watch,Gulp,Gulp Watch,查看根gulp项目目录中的所有less文件,然后只编译保存的less文件。我无法通过第一部分 当我在项目目录中运行$gulp watch时,它会挂起。开始执行任务,但从未完成 var gulp = require('gulp'); var less = require('gulp-less'); var path = require('path'); gulp.task('compileCurrentTheme', function () { return gulp.src('./*.les
var gulp = require('gulp');
var less = require('gulp-less');
var path = require('path');
gulp.task('compileCurrentTheme', function () {
return gulp.src('./*.less')
.pipe(less({
compress: true
}))
.pipe(gulp.dest('./'));
});
// Gulp watch functions
gulp.task('watch', function(){
gulp.watch('*.less', ['compileCurrentTheme']);
});
你犯了一些错误
gulp.task('compileCurrentTheme', function () {
return gulp.src('./*.less') // ./ -> root directory
.pipe(less())
.pipe(gulp.dest('yourPath')); // you can also type ./ it will create .css files in your root directory
});
// Gulp watch functions
gulp.task('watch:less', function(){
gulp.watch('./*.less', ['compileCurrentTheme']);
});
将watch
任务重命名为watch:less
,然后从控制台运行gulp watch:less
请看一看,特别是吞下手表
,让您的理解更清楚一点
我希望它能帮助你
谢谢更新了我的代码以反映您的建议。仍然挂着。[14:48:16]使用gulpfile~/Sites/gdw/thedentalistecontent/themes/gulpfile.js[14:48:16]启动“监视”…@justin当您按save时,它将如何重新运行
compileCurrentTheme
任务?开始任务却从未完成——因为gulp正在等待您的更改,这就是它没有完成的原因。这是正常的行为,事实上,这是有效的。看来gulp正被那个目录中的其他东西挂掉。不。我可以手动运行compileCurrentTheme任务。手表任务挂起。事实上,我以前是错的。它起作用了。监视任务需要很长时间才能运行。这个项目的根目录中有几百个目录。有没有办法将它们从手表中排除,这样执行速度会更快?那就看根目录吧?