Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using grunt to build bower components

Tags:

gruntjs

bower

How do I configure my Gruntfile to run the build scripts for my bower components?

One issue is that each component may have a different build command, for example D3 uses a Makefile, so I need to run make, and angular.js also uses grunt and needs to run grunt build.

Can someone point me to an example of this?

like image 604
user1027169 Avatar asked May 28 '13 19:05

user1027169


2 Answers

Bower components should be built.

Otherwise users are going to be in the exact situation you're in. I know many components currently aren't, but there's not much we can do about it.

You can use grunt-shell to easily execute whatever build scripts you need to:

grunt.initConfig({
    shell: {
        d3: {
            command: 'make',
            options: {
                execOptions: {
                    cwd: 'components/d3'
                }
            }
        },
        angular: {
            command: 'grunt',
            options: {
                execOptions: {
                    cwd: 'components/angular'
                }
            }
        }
    }
});
like image 107
Sindre Sorhus Avatar answered Nov 10 '22 08:11

Sindre Sorhus


I have been using Grunt Task for Bower to do the build.

You may find it useful.

After setup, you can copy all the required components in this way

grunt bower:install
like image 4
Ian Lim Avatar answered Nov 10 '22 07:11

Ian Lim