From be2ad22bfa07dec9f2357d78e96763c4b5f44b02 Mon Sep 17 00:00:00 2001 From: Geneller Naranjo Date: Wed, 25 Jan 2017 08:52:58 -0500 Subject: [PATCH 1/3] Uglifyjs with sourcemaps option and file list. --- src/Filter/Uglifyjs.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Filter/Uglifyjs.php b/src/Filter/Uglifyjs.php index 4dbcf407..8b0d8ab0 100644 --- a/src/Filter/Uglifyjs.php +++ b/src/Filter/Uglifyjs.php @@ -32,6 +32,17 @@ class Uglifyjs extends AssetFilter 'options' => '', ); + /** + * Input filter. + * + * @param string $filename Name of the file + * @param string $content Content of the file. + * @return string + */ + public function input($filename, $content) { + $this->files[] = $filename; + return $content; + } /** * Run `uglifyjs` against the output and compress it. * @@ -41,8 +52,19 @@ class Uglifyjs extends AssetFilter */ public function output($filename, $input) { - $cmd = $this->_settings['node'] . ' ' . $this->_settings['uglify'] . ' - ' . $this->_settings['options']; + $files = implode(' ', $this->files); + $cmd = + $this->_settings['node'] . ' ' . + $this->_settings['uglify'] . ' ' . + $files . ' ' . + $this->_settings['options']; + + if ($this->_settings['create_map']) { + $cmd .= ' ' . $this->_settings['source_map']; + } + + // $cmd = $this->_settings['node'] . ' ' . $this->_settings['uglify'] . ' - ' . $this->_settings['options']; $env = array('NODE_PATH' => $this->_settings['node_path']); - return $this->_runCmd($cmd, $input, $env); + return $this->_runCmd($cmd, '', $env); } } From 9eba59321af042d666fa855eadfcaf2774d2e431 Mon Sep 17 00:00:00 2001 From: Geneller Naranjo Date: Thu, 26 Jan 2017 06:05:38 -0500 Subject: [PATCH 2/3] PSR-2 fixes, create_map options no longer needed. --- src/Filter/Uglifyjs.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Filter/Uglifyjs.php b/src/Filter/Uglifyjs.php index 8b0d8ab0..4372720a 100644 --- a/src/Filter/Uglifyjs.php +++ b/src/Filter/Uglifyjs.php @@ -39,7 +39,8 @@ class Uglifyjs extends AssetFilter * @param string $content Content of the file. * @return string */ - public function input($filename, $content) { + public function input($filename, $content) + { $this->files[] = $filename; return $content; } @@ -59,10 +60,6 @@ public function output($filename, $input) $files . ' ' . $this->_settings['options']; - if ($this->_settings['create_map']) { - $cmd .= ' ' . $this->_settings['source_map']; - } - // $cmd = $this->_settings['node'] . ' ' . $this->_settings['uglify'] . ' - ' . $this->_settings['options']; $env = array('NODE_PATH' => $this->_settings['node_path']); return $this->_runCmd($cmd, '', $env); From 83bae0fc66c4632c5589de922c134a231fa48545 Mon Sep 17 00:00:00 2001 From: Geneller Naranjo Date: Thu, 26 Jan 2017 21:16:33 -0500 Subject: [PATCH 3/3] Remove commented out line. --- src/Filter/Uglifyjs.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Filter/Uglifyjs.php b/src/Filter/Uglifyjs.php index 4372720a..f587512c 100644 --- a/src/Filter/Uglifyjs.php +++ b/src/Filter/Uglifyjs.php @@ -60,7 +60,6 @@ public function output($filename, $input) $files . ' ' . $this->_settings['options']; - // $cmd = $this->_settings['node'] . ' ' . $this->_settings['uglify'] . ' - ' . $this->_settings['options']; $env = array('NODE_PATH' => $this->_settings['node_path']); return $this->_runCmd($cmd, '', $env); }