Sharing the Code

Programming stuff that might be useful to others

Calling Grunt from Ant

I’ve been using Apache Ant to deploy to servers for a number of years but I’ve been using Grunt for client-side development recently. Before I package up my website and deploy to a server I might want to minify the CSS and Javascript and that’s where Grunt comes in. I’ve created a ‘build’ task in Grunt that gets Compass to output ‘compressed’ CSS and use Uglify to minify my Javascript. Grunt requires Node.js and Compass requires Ruby. I use RVM so I can have multiple versions of Ruby on my system. To run the Grunt task from Ant you will need to add Node to the path and ‘source’ the RVM script so it has access to the RVM function. My client-side project directory (which is a Drupal Omega 4 subtheme) has .ruby-version and .ruby-gemset files which contain the Ruby and Gemset versions that the project uses. When you change into the project directory RVM uses these files to change the current Ruby and Gemset versions. You might need to change local.nodePath and local.rvmPath. I’ve done a multi-user installation of RVM. For a single-user installation RVM is likely to be in ~/.rvm/

[sourcecode language=”xml”]





[/sourcecode]

Comments are closed