Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Uglifyjs with sourcemaps option and file list. #38

wants to merge 3 commits into from

Conversation

genellern
Copy link

@genellern genellern commented Jan 26, 2017

Uglifyjs doesn't create source maps from STDIN, so we need the list of files.

You could put the domain in the asset_compress.ini like
--source-map-url http/yourdomain/cached_js/scripts.js.map.
And the option to create it.
create_map = true.

* @param string $content Content of the file.
* @return string
*/
public function input($filename, $content) {
Copy link
Contributor

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

@codecov-io
Copy link

codecov-io commented Jan 26, 2017

Current coverage is 86.68% (diff: 0.00%)

Merging #38 into master will decrease coverage by 0.59%

@@             master        #38   diff @@
==========================================
  Files            35         35          
  Lines          1022       1029     +7   
  Methods         173        174     +1   
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits            892        892          
- Misses          130        137     +7   
  Partials          0          0          

Powered by Codecov. Last update 18d2be3...83bae0f

@markstory markstory added this to the 1.4.0 milestone Jan 26, 2017
Copy link
Owner

@markstory markstory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an example of how the sourcemap options would be used in a config file?

@@ -41,8 +53,15 @@ class Uglifyjs extends AssetFilter
*/
public function output($filename, $input)
{
$cmd = $this->_settings['node'] . ' ' . $this->_settings['uglify'] . ' - ' . $this->_settings['options'];
$files = implode(' ', $this->files);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this correctly escape files with spaces in their names?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No for relative paths.

$files . ' ' .
$this->_settings['options'];

// $cmd = $this->_settings['node'] . ' ' . $this->_settings['uglify'] . ' - ' . $this->_settings['options'];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you delete this instead of leaving behind commented out code?

@genellern
Copy link
Author

genellern commented Jan 27, 2017

In the compress_asset.ini file:

[filter_Uglifyjs]
options = -c --source-map-include-sources --source-map-url http://domain/cached_js/scripts.js.map --source-map WEBROOT/cache_js/scripts.js.map

@markstory
Copy link
Owner

Thanks, I can use that to update the documentation.

@cleptric
Copy link

@markstory Is there sth else to do? I really need this feature :)

@genellern
Copy link
Author

genellern commented Feb 15, 2017

I tried with realpath() to get it to work with file names with spaces, but I get errors at the helper level, which is beyond the scope of this PR.

$env = array('NODE_PATH' => $this->_settings['node_path']);
return $this->_runCmd($cmd, $input, $env);
return $this->_runCmd($cmd, '', $env);
Copy link
Owner

Choose a reason for hiding this comment

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants