-
Notifications
You must be signed in to change notification settings - Fork 17
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
Uglifyjs with sourcemaps option and file list. #38
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this correctly escape files with spaces in their names? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No for relative paths. |
||
$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']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you delete this instead of leaving behind commented out code? |
||
$env = array('NODE_PATH' => $this->_settings['node_path']); | ||
return $this->_runCmd($cmd, $input, $env); | ||
return $this->_runCmd($cmd, '', $env); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this break filter chains that involve pre-processors and uglify? For example combining the coffescript or sprockets filter and uglify will no longer work as uglify will be told to use the source files and not the transformed results of those files. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opening brace should be on a new line