我有来自https://github.com/gulpjs/gulp的gulpfile.js。 我只是改变我的文件夹名称。 任务'gulp'正常工作,首先'gulp watch'。但任何其他保存任何较少的文件都不会做任何事情。仅仅在1.34秒后“完成'风格'” (JS工作得很好)
有什么建议吗? main.less与所有filles的进口量减少 文件夹看起来像:
/www
/js
/css
main.less
file.less
file2.less
/lib
file3.less
var gulp = require('gulp');
var less = require('gulp-less');
var babel = require('gulp-babel');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var cleanCSS = require('gulp-clean-css');
var del = require('del');
var paths = {
styles: {
src: 'www/css/main.less',
dest: 'www/css/'
},
scripts: {
src: 'www/js/js/**/*.js',
dest: 'www/js/'
}
};
function clean() {
return del([ 'assets' ]);
}
function styles() {
return gulp.src(paths.styles.src)
.pipe(less())
.pipe(cleanCSS())
// pass in options to the stream
.pipe(rename({
basename: 'main',
suffix: '.min'
}))
.pipe(gulp.dest(paths.styles.dest));
}
function scripts() {
return gulp.src(paths.scripts.src, { sourcemaps: true})
.pipe(babel())
.pipe(uglify())
.pipe(concat('all.min.js'))
.pipe(gulp.dest(paths.scripts.dest));
}
function watch() {
gulp.watch("www/js/js**/*.js", scripts);
gulp.watch("www/css/**/*.less", styles);
}
exports.clean = clean;
exports.styles = styles;
exports.scripts = scripts;
exports.watch = watch;
var build = gulp.series(clean, gulp.parallel(styles, scripts));
gulp.task('build', build);
gulp.task('default', build);
答案 0 :(得分:0)
正如@Jakub所想,你实际上从未在你提供的代码中调用你的手表任务!你可能想要这样的东西:
var build = gulp.series(clean, gulp.parallel(styles, scripts), watch);