@@ -131,6 +131,20 @@ class Manager
131131 */
132132 protected $ notify_command ;
133133
134+ /**
135+ * Closure used by the pipeline to minify CSS assets.
136+ *
137+ * @var Closure
138+ */
139+ protected $ css_minifier ;
140+
141+ /**
142+ * Closure used by the pipeline to minify JavaScript assets.
143+ *
144+ * @var Closure
145+ */
146+ protected $ js_minifier ;
147+
134148 /**
135149 * Available collections.
136150 * Each collection is an array of assets.
@@ -191,8 +205,8 @@ public function config(array $config)
191205 if (isset ($ config [$ option ]))
192206 $ this ->$ option = $ config [$ option ];
193207
194- // Set pipeline commands
195- foreach (array ('fetch_command ' , 'notify_command ' ) as $ option )
208+ // Set pipeline options
209+ foreach (array ('fetch_command ' , 'notify_command ' , ' css_minifier ' , ' js_minifier ' ) as $ option )
196210 if (isset ($ config [$ option ]) and ($ config [$ option ] instanceof Closure))
197211 $ this ->$ option = $ config [$ option ];
198212
@@ -429,10 +443,13 @@ public function resetJs()
429443 */
430444 protected function cssPipeline ()
431445 {
432- return $ this ->pipeline ($ this ->css , '.css ' , $ this ->css_dir , function ($ buffer ) {
446+ // If a custom minifier has been set use it, otherwise fallback to default
447+ $ minifier = (isset ($ this ->css_minifier )) ? $ this ->css_minifier : function ($ buffer ) {
433448 $ min = new \CSSmin ();
434449 return $ min ->run ($ buffer );
435- });
450+ };
451+
452+ return $ this ->pipeline ($ this ->css , '.css ' , $ this ->css_dir , $ minifier );
436453 }
437454
438455 /**
@@ -442,9 +459,12 @@ protected function cssPipeline()
442459 */
443460 protected function jsPipeline ()
444461 {
445- return $ this ->pipeline ($ this ->js , '.js ' , $ this ->js_dir , function ($ buffer ) {
462+ // If a custom minifier has been set use it, otherwise fallback to default
463+ $ minifier = (isset ($ this ->js_minifier )) ? $ this ->js_minifier : function ($ buffer ) {
446464 return \JSMin::minify ($ buffer );
447- });
465+ };
466+
467+ return $ this ->pipeline ($ this ->js , '.js ' , $ this ->js_dir , $ minifier );
448468 }
449469
450470 /**
0 commit comments