Michael M
Michael M

Reputation: 21

How to get rid of Gulp's "Task never defined: default"?

I am using an existing Gulp script that someone else made and it's interesting that a similar one for JS works fine, but this one for styles, doesn't. The code:

'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

Excerpt from css-compressor.js:

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

Can you help? Thank you!

Upvotes: 2

Views: 324

Answers (1)

Jérôme
Jérôme

Reputation: 1128

You need to declare a default task in the end.

Using Gulp 3.x:

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

Using Gulp 4.x:

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

Replace styles, scripts and images by your tasks.

Upvotes: 1

Related Questions