如何摆脱Gulp的“任务从未定义:默认”?

我使用的是其他人制作的现有Gulp脚本,有趣的是,类似的JS脚本可以很好地工作,但是这种样式却不能。 编码:

'use strict';
const
 path = require('path'),
 pathToLibs = path.resolve('../../../../libs');
const
 {CssCompressor} = require('css-compressor.js'),
 compressor = new CssCompressor(false),
 resolveLocalSrc = function (files) {
   return files.map(item => path.resolve(__dirname, item));
 },
 resolveLibsSrc = function (files) {
   return files.map(item => path.resolve(pathToLibs, item));
 };

let sources = {
 "cache_main.css": [].concat(
   resolveLocalSrc([
     "scss/design-core.scss"
   ]),
   resolveLibsSrc([
     "vendor/jquery/dropzone-4.3.0/dropzone.css"
   ]),
   resolveLocalSrc([
     "../scripts/jquery/whatever.css",
     "scss/whatever.scss",
   ])
 ),
 "cache_light.css": resolveLocalSrc(["scss/design-core.scss"])
};
compressor.makeCache(sources, './', ["scss/*.scss"]);

When running gulp, it says: Task never defined: default

css-compressor.js的摘录:

  makeCache(sources, dest = './', additionalDirsToWatch=[]) {
    Object.entries(sources).forEach(([cacheFileName, files]) => {
      gulp.task('compress ' + cacheFileName, () => {
        this.compress(files, cacheFileName, dest);
      });
    });

你能帮我吗? 谢谢!

评论
毛毛虫
毛毛虫

最后,您需要声明一个默认任务。

使用Gulp 3.x:

gulp.task('default', ['styles', 'scripts', 'images']);

使用Gulp 4.x:

gulp.task('default', gulp.parallel('styles', 'scripts', 'images'));

用您的任务替换样式,脚本和图像。

点赞
评论