Skip to content

Instantly share code, notes, and snippets.

@heldr
Last active August 26, 2020 12:24
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save heldr/a3429c31ff45937c13de to your computer and use it in GitHub Desktop.
Save heldr/a3429c31ff45937c13de to your computer and use it in GitHub Desktop.
Another way of splitting a gulpfile into multiple files
/*
Another way of splitting a gulpfile into multiple files based on:
http://macr.ae/article/splitting-gulpfile-multiple-files.html
https://github.com/gulpjs/gulp/blob/master/docs/recipes/split-tasks-across-multiple-files.md
*/
'use strict';
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')(),
taskPath = './tasks/',
// async readdir does not identify task names
taskList = require('fs').readdirSync(taskPath);
taskList.forEach(function (taskFile) {
// or .call(gulp,...) to run this.task('foobar')...
require(taskPath + taskFile)(gulp, plugins);
});
module.exports = function (gulp, $) {
'use strict';
gulp.task('styles', function () {
return gulp.src(['app/public/scss'], { dot: false })
.pipe($.sass())
.pipe(gulp.dest('dist/css'))
});
};
@slavafomin
Copy link

Hello!

Thank you for your example!

I just wanted to advertise the gulp-require-tasks module, that I've created to solve this specific task.
Please consider using it and let me know if it works for you!

If you have any suggestions or ideas for improvement, I will gladly accept them.

Have a good day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment