Last active
August 26, 2024 11:06
-
-
Save heldr/a3429c31ff45937c13de to your computer and use it in GitHub Desktop.
Another way of splitting a gulpfile into multiple files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!