0

I'm trying to split my gulpfile.js to multiply files (due to the amount of tasks). My files structure looks like this:

./
  - gulpfile.js/
    - index.js
    - tasks/
      - cleanup.js
      - main.js

index.js:

const requireDir = require('require-dir');
requireDir('./tasks');

cleanup.js:

const
     gulp  = require('gulp'),
     del   = require('del');

function cleanup() {

  return del([/files_to_delete], {
                force: true,
  });

}
 exports.cleanup = cleanup;

main.js:

const

    gulp            = require('gulp'),
    requireDir      = require('require-dir'),
    path            = process.cwd() + '/gulpfile.js/tasks';

    requireDir(path, { recurse: true });


gulp.task('default', cleanup);

Result:

ReferenceError: cleanup is not defined

For some reason cleanup is not being imported. Any help will be much appreciated.

Thanks

Dom
  • 3,126
  • 14
  • 46
  • 68

0 Answers0