How To Use Bower And Grunt For Grails Asset Pipeline

Do you like this?

This tutorial shows you the steps to manage static javascript files using Bower and Grunt for Grails projects.


1) Install npm
2) grails create-app BowerGrails
3) cd BowerGrails
4) npm install grunt-cli -g
5) npm install bower -g
6) npm init
Accept default values for all questions
7) bower init
Accept default values for all questions
8) bower install jquery -save
9) npm install grunt --save-dev
10) npm install grunt-contrib-copy --save-dev
11) Create Gruntfile.js with the following content:

module.exports = function(grunt) {
    pkg: grunt.file.readJSON('package.json'),
    copy: {
	  main: {
	    files: [
	      // includes files within path
	      {expand: true, cwd:'bower_components', src: ['jquery/dist/jquery.js'], dest: 'grails-app/assets/javascripts/', 
	      		flatten: true, filter: 'isFile' },

12) grunt copy
Now you should see jquery.js has been copied to the assets/javascripts folder

comments powered by Disqus