gulp-gm icon indicating copy to clipboard operation
gulp-gm copied to clipboard

gm config options in a separate file

Open adrinux opened this issue 9 years ago • 1 comments

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

adrinux avatar Feb 12 '16 17:02 adrinux

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);
}))

normanrz avatar Feb 15 '16 15:02 normanrz