-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure tasks #120
Comments
May be related to robrich/orchestrator#17 What exactly are you trying to do? |
For example, I want this task to have parameters for the different folders used.
What do you think about it (just idea of the possible code, doesn't work obviously) ? |
My usual work around for this kind of thing is that, since it's javascript, you can wrap a function: var do_stuff = function(config) {
return gulp.src(config.patternFiles)
.pipe(uglify())
.pipe(gulp.dest(config.destinationPath));
}
gulp.task('dev', function () {
do_stuff({
patternFiles: ['dev/desktop/js/**/*.js', '!dev/desktop/js/vendor/**'],
destinationPath: 'build/desktop/js'
});
do_stuff({
patternFiles: ['dev/mobile/js/**/*.js', '!dev/mobile/js/vendor/**'],
destinationPath: 'build/mobile/js'
});
}); |
also, you can export some settings to json files and just require them, like config.json {
"desktop" : {
"src" : [ "dev/desktop/js/**/*.js", "!dev/desktop/js/vendor/**"],
"dest" : "build/desktop/js"
},
"mobile" : {
"src" : [ "dev/mobile/js/**/*.js", "!dev/mobile/js/vendor/**"],
"dest" : "build/mobile/js"
}
} gulpfile.js // ...
var config = require('./path/to/config.json');
function doStuff(cfg) {
return gulp.src(cfg.src)
.pipe(uglify())
.pipe(gulp.dest(cfg.dest));
}
gulp.task('dev', function () {
doStuff(config.desktop);
doStuff(config.mobile);
}); |
@stryju nice! i hadn't thought of that one. |
@travm Consider #120 (comment) to include to the frontend book? |
lol. @stryju book in question is https://github.com/tooling/book-of-modern-frontend-tooling |
had a quick look and it looks like some1 tackled that topic already (in grunt section, so still a valid suggestion to use it in gulp as well) ;-) tooling/book-of-modern-frontend-tooling#2 (comment) |
Thanks guys. I thank about a similar way. I just wanted to know if gulp maybe think about an integration directly in the tasks. Let's use that for now 😃 |
I close the issue. Maybe adding @stryju idea to a best practises wiki page ? |
PR ready ;-) |
@travm note compatibility with grunt. |
Hi guys,
I just switched from Grunt and I find with gulp, that there is no way to configure tasks. I know gulp hasn't the same philosophy as Grunt but I have some cases where I need to run tasks but with different configurations while I don't want to copy paste code too.
Can you help me ?
The text was updated successfully, but these errors were encountered: