Uglifyjs is a JavaScript parser/compressor/beautification tool. It can be used to combine and shrink multiple JavaScript resources, making them require fewer HTTP requests and making your site load faster. uglifycss is a CSS compressor/beautification tool that works similarly to UGLIFYJS.
How to install under Windows:
1. Installing Nodejs and NPM tools
Because Nodejs comes with NPM tools, it is possible to install Nodejs directly.
Open http://nodejs.org/, click Install in the webpage, download the corresponding MSI file and install
2. Enter your Symfony2 root directory in cmd
CD E:\xampp\htdocs\symfony
3. Install Uglify-js and uglifycss to your App/resources/node_modules directory
NPM Install uglify-js--prefix app/resourcesnpm install uglifycss--prefix app/resources
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4B/C2/wKioL1Qx9-LhblAqAADtaHnf4-I699.jpg "title=" Qq20141006095958.png "alt=" Wkiol1qx9-lhblaqaadtahnf4-i699.jpg "/>
4, Configuration Symfony
# app/config/config.ymlassetic:bundles: [Acmedemobundle] # [] is your bundle name node: "D:\Program Files\nodejs" # your Nodejs installs the path filters:uglifyjs2:bin: "%kernel.root_dir%/resources/node_modules/.bin/uglifyjs. CMD "#npm安装的路径 uglifycss:bin:"%kernel.root_dir%/resources/node_modules/.bin/uglifycss.cmd "
5. Use:
{% stylesheets ' bundles/acmefoo/css/* ' filter= ' uglifycss ' filter= ' cssrewrite '%} <link rel= "stylesheet" href= "{{as Set_url}} "/>{% endstylesheets%}
{% javascripts ' @AcmeFooBundle/resources/public/js/* ' filter= '? Uglifyjs2 '%} <script src= ' {{asset_url}} ' ></ script>{% endjavascripts%}
Reference: http://symfony.com/doc/current/cookbook/assetic/uglifyjs.html
This article is from the "Tech Tech" blog, so be sure to keep this source http://baoniu.blog.51cto.com/9450787/1560785
Windows Symfony2 installation of UGLIFYJS2 and UGLIFYCSS