Last active
August 29, 2015 13:59
-
-
Save ilya-dev/10747973 to your computer and use it in GitHub Desktop.
Laravel Task Runner - how that might look like
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
<?php | |
// in app/tasks.php | |
// the second argument contains the array of "dependencies" | |
task("default", ["minify_css", "minify_js", "concatenate"]); | |
// smart enough to analyze the arguments | |
// and "inject" required components | |
task("minify_css", function($minifyCss) | |
{ | |
// read as: | |
// "scan the directory app/assets/css" and pipe all files through | |
// $minifyCss component, then save it to public/css | |
$this->in('app/assets/css')->pipe($minifyCss())->out('public/css'); | |
}); | |
task("minify_js", function($minifyJs) | |
{ | |
// you can even pass settings! | |
$settings = [ | |
'keepComments' => true, | |
]; | |
$this->in('app/assets/js')->pipe($minifyJs($settings))->out('public/js'); | |
}); | |
task("concatenate", function($concatenator) | |
{ | |
$this->in('public/js')->pipe($concatenator())->out('public/main.js'); | |
$this->in('public/css')->pipe($concatenator())->out('public/main.css'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment