Struggling with gulpfile

Hi guys,

I’m trying to split my gulp tasks between several files but I think I’m doing something wrong because I keep getting “task never defined” error when I run ‘gulp style’. Here’s what gulp doc page has to say about splitting the file:

Each task can be split into its own file, then imported into your gulpfile for composition. Not only does this keep things organized, but it allows you to test each task independently or vary composition based on conditions. Node’s module resolution allows you to replace your gulpfile.js file with a directory named gulpfile.js that contains an index.js file which is treated as a gulpfile.js . This directory could then contain your individual modules for tasks.

I did all that. Got gulpfile.js folder, with index.js and my task files (style.js and watchjs).

Here’s what my style.js looks like:

const gulp = require('gulp');
const sass = require('gulp-sass');

// compile scss into css
function style() {
  return gulp.src('./src/styles/**/*.scss')
    .pipe(sass())
    .pipe(gulp.dest('./dist/css'));
}

exports.style = style;

And here’s what my index.js looks like:

const style = require('./style');
const watch = require('./watch');

exports.style = style;
exports.watch = watch;

If someone could help me make sense of this, I’d really appreciate it.

const { style } = require('./style');