V
V
Vladimir2019-03-22 16:50:36
JavaScript
Vladimir, 2019-03-22 16:50:36

Why are Gulp tasks not loading?

I decided the other day to rewrite the config for Gall. And everything broke.
In short: taxis are in /tasks, the gulpfile.babel.js file works through Babel.
Galp gulp buildgives an error on startup:

AssertionError [ERR_ASSERTION]: Task never defined: clean
    at getFunction (/Users/vovaspace/dev/rr-project/node_modules/undertaker/lib/helpers/normalizeArgs.js:15:5)
    at map (/Users/vovaspace/dev/rr-project/node_modules/arr-map/index.js:20:14)
    at normalizeArgs (/Users/vovaspace/dev/rr-project/node_modules/undertaker/lib/helpers/normalizeArgs.js:22:10)
    at Gulp.series (/Users/vovaspace/dev/rr-project/node_modules/undertaker/lib/series.js:13:14)
    at Object.<anonymous> (/Users/vovaspace/dev/rr-project/tasks/build.js:3:25)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at loader (/Users/vovaspace/dev/rr-project/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/vovaspace/dev/rr-project/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)

There is an error on clean, but if you remove it, the error will be on the next task. In this case, individual tasks are launched normally.
gulpfile.babel.js
const requireDir = require('require-dir');
requireDir('tasks');

tasks/build.js
import gulp from 'gulp';

gulp.task('build', gulp.series(
  'clean',
  'styles',
  'templates',
  'scripts'
));

At the same time, if you rename build.js to zzz.js (that is, make it last alphabetically), everything works. Could it be a problem with the order of the files in the folder?
Where to dig?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
inzeppelin, 2019-03-22
@inzeppelin

Could it be a problem with the order of the files in the folder?

Maybe. require-dir imports files in alphabetical order.

V
Vladimir, 2019-03-22
@notnlwns

Solved the issue like this:

import './tasks/clean';
import './tasks/fonts';
import './tasks/images';
import './tasks/scripts';
import './tasks/server';
import './tasks/sprites';
import './tasks/styles';
import './tasks/templates';

import './tasks/watch';
import './tasks/build';
import './tasks/deploy';
import './tasks/default';

If there are better solutions, please suggest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question