load-tasks
A plugin to output a file/task object based on a passed in folder/array of folders.
Usage
The examples below show the usage within gulp, but should work with grunt or any other build system (or even outside of a build system!)
Given the following directory structure:
├── build
├── tasks
└── sass.js
└── watch.js
└── webpack.js
└── gulpfile.babel.js
gulpfile.babel.js
; ;;; const tasks = './build/tasks'gulp args: argv pkg; gulp;gulp;gulp; gulp);
Note that any arguments passed to the closure (2nd function call) are passed to the imported tasks/files, if any tasks/files export a function!
build/tasks/sass.js
'use strict';; // note that both es6 and commonjs exports can be used, but es6 exports need to export `default` { return { return gulp ; };};
const tasks
is now an object populated with the exported contents of each of the tasks, e.g.
{ // the gulp sass function we defined above! } { // whatever `watch.js` exports! } { // whatever `webpack.js` exports! }