Skip to content

Assetic/uglifyjs cookbook article #2406

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

Closed
wants to merge 5 commits into from
Closed

Assetic/uglifyjs cookbook article #2406

wants to merge 5 commits into from

Conversation

Sgoettschkes
Copy link
Contributor

This PR involves a new cookbook describing how to use uglifyjs with assetics.

Q A
Doc fix? no
New docs? yes
Applies to 2.0+
Fixed tickets #1841,#1099

Right now, I copied the yuicomposer cookbook and changed it tto uglifyjs where needed. Please suggest further changes to improve this cookbook.

Pleae also have a look at how the installation of ugliffyjs is done and if this fits "our" view of how it should be installed.


.. code-block:: bash

$ npm install uglifyjs /path/to/symfony/app/Resources
Copy link
Member

Choose a reason for hiding this comment

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

Be careful. This will install uglifyJs 2 by default while you use the filter for uglifyJs 1 later (there is 2 different filters in Assetic as the version 2 is not BC with the version 1)

.. tip::

This cookbook uses UglifyJs 1 instead of the newer version 2 to be compatible
with old assetic versions. If you wantt to use UglifyJs version 2, make sure
Copy link
Contributor

Choose a reason for hiding this comment

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

@Sgoettschkes There is a small typo with 'wantt'

@peterrehm
Copy link
Contributor

@Sgoettschkes @wouterj How about mentioning UglifyCSS as well?

By the way, for me the install command was not working. I am getting errors with
that. Only global install worked at the end.

single: Assetic; UglifyJs

How to Minify JavaScripts with UglifyJs
=======================================
Copy link
Member

Choose a reason for hiding this comment

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

I think we should rename this entry so that it's more like an example of using a minification filter, where we use ugllifyjs as an example:

How to Minify CSS/JS Files (using UglifyJs and UglifyCss)

Then we can make some slight changes to make this entry a bit more general:

  • An intro paragraph that talks about how you can use different filters to minify CSS and JS files. We could mention the other filters available to do this: yui css, yui js (both deprecated), Closure, cssmin, jsmin, jsminplus.
  • Add a section about using UglifyCss. But here, we can skip most of the details - i.e. we don't need to really show detailed install, since we've shown for UglifyJS. We can also have a shorter configuration section.
  • Tweak the "Disable Minification in Debug Mode" section to use UglifyJs as an example, but talk more generally about how this can be used on any filter.

@weaverryan
Copy link
Member

@Sgoettschkes I've just added a few comments! After that, I'll try the code out for myself and merge this. Very nice entry and important for us to get this up there in place of YUI!

Thanks!

@Sgoettschkes
Copy link
Contributor Author

@weaverryan Thanks for your input.

Regarding your first bulletpoint (intro paragraph): Isn't that covered by http://symfony.com/doc/current/cookbook/assetic/asset_management.html?

@Sgoettschkes
Copy link
Contributor Author

@weaverryan Bullet point two is clear, but I don't know how to make the "Disable Minification in Debug Mode" section more general (bullet point three). Beside the configuration example, it is pretty general.

@gnugat
Copy link

gnugat commented May 27, 2013

Thanks to this documentation, I now know how to use Uglify to inify my assets instead of YUI compressor :) .
I hope it gets merged as soon as possible (hopefully before the release of Symfony 2.3), if there are any improvements to be done they can surely be done afterwards.

@Sgoettschkes
Copy link
Contributor Author

Thanks for testing!

I am currently waiting for feedback/improvement suggestions. From my point of view this is ready to be merged!

weaverryan added a commit that referenced this pull request Jun 12, 2013
* Updating some language
* Adding additional clarification details
* Updating to use UglifyJS version 2, since this is merged into Symfony 2.2, which uses an AsseticBundle that supports this Uglify version
@weaverryan
Copy link
Member

Hi guys!

I've just patched this into the 2.2 branch at the following shas:

The good news about the delay in merging this is that 2.1 has reached its end of maintenance, so I merged this into the 2.2 branch, which does support UglifyJS version 2. I updated the entry to reflect that and made other changes at sha: 28f4ae7. I also fixed the local installation. I prefer to use a package.json to install npm dependencies, but I'm not sure if that should be the standard approach that we recommend or not. I do think it's better, but we're also not Node developers, so it's a balance of keeping the barrier low.

As always, if anyone notices any mistakes I've made, please let me know! And thanks very much to Sebastian for putting the work together for this entry!

Cheers!

@weaverryan weaverryan closed this Jun 12, 2013
@Sgoettschkes
Copy link
Contributor Author

I personally don't like the package.json, simple because this project is not a Node project and uglifyjs is "just a tool". But I don't think it makes a huge difference.

Thanks for imprving the article and updating it to 2.2 and UglifyJs 2!

@gnugat
Copy link

gnugat commented Jun 12, 2013

Will this be also available in 2.4 and master branches?

@Sgoettschkes Sgoettschkes deleted the issue1841 branch November 30, 2013 16:31
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