gulp-gm
gulp-gm copied to clipboard
gm config options in a separate file
I've been writing a gulpfile and trying to keep configuration options in a separate file when they're likely to be changed. Can anyone suggest a practical way to split out the callback?
Here's the links to my work in progress: gulpfile is at https://github.com/adrinux/web-starter-hugo/blob/master/gulpfile.js config file is at https://github.com/adrinux/web-starter-hugo/blob/master/config/config.js
Do I understand correctly that you want to split out this callback into a config object in a separate file? https://github.com/adrinux/web-starter-hugo/blob/master/gulpfile.js#L41-L44
This module doesn't support configuration objects out of the box, but you could write a function that takes a config like var actions = [{ name: "resize", args: [1280, 1024] }]
and applies it like this:
// ES2015
.pipe(plugins.gm(function (gmfile) {
return actions.reduce((gmfile, action) => gmfile[action.name](...action.args), gmfile);
}))