无Gulp的4.0.1和Gulp 4.0.0不会创建输出CSS

时间:2018-09-28 14:07:09

标签: gulp gulp-less

我安装了Gulp 4.0.0,gulp cli 3.9.1和无gulp 4.0.0。
我了解无gulp 4.0.1需要gulp3.x。
问题是“如何在gulp 4中少用?”
控制台和gulp-util没有显示任何错误,但似乎可以忽略较少的任务。

Package.json:

{
  "name": "quests",
  "version": "1.0.0",
  "description": "quests",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Toma",
  "license": "ISC",
  "devDependencies": {
    "gulp": "^4.0.0",
    "gulp-less": "^4.0.1"
  }
}

Gulpfile.js:

var gulp = require("gulp"); 
var less = require('gulp-less');

gulp.task('less', function () {
    return gulp.src('less/*.less')
        .pipe(less())
        .pipe(gulp.dest("dist/css"));
});

gulp.task('watch', function(){
    gulp.watch("src/less/*.less").on('change', function(event) {
        console.log(event.path);
        console.log(event.type);
    });
});

gulp.task('default', gulp.series(['less', 'watch'], function(done) {
    done();
}));

控制台:

[16:53:20] Using gulpfile ~\Documents\quests\gulpfile.js
[16:53:20] Starting 'default'...
[16:53:20] Starting 'less'...
[16:53:21] Finished 'less' after 45 ms
[16:53:21] Starting 'watch'...

0 个答案:

没有答案