Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How make bower build the package?

Is there a way to make bower run a package grunt after it was cloned from GitHub?

I'm trying to use Bower but one of the packages I'm using is the Bootstrap extension, x-editable. The problem is that while other packages push a fully built version to github so when installed by Bower you have a built version x-editable expect you to run a grunt file to build the package.

That is a common practice in other package managers like npm but I could find how to make Bower build it on install. Which means I need another mechanism to complete the installation of the package.

like image 213
Guy Korland Avatar asked Jun 18 '13 13:06

Guy Korland


2 Answers

Building on install is an anti-pattern and is strongly recommended against in Node. Like Node, Bower packages should be pre-built. This is because the end-user shouldn't have to care what preprocessor or build-system a package requires.

Your best options are to either convince the author to pre-build, fork and do it yourself, or build manually after you've installed the component.

The Bower team is planning to add the ability to publish packages to a server similar to how it works in npm. This will make it much better for packages needing a build-step.

like image 186
Sindre Sorhus Avatar answered Sep 21 '22 07:09

Sindre Sorhus


There are 3 hooks in bower, postinstall may solve your problem if for whatever reason you can not pre-built like @Sindre Sorhus points out.

In .bowerrc do:

{
    "scripts": {
        "preinstall": "<your command here>",
        "postinstall": "<your command here>",
        "preuninstall": "<your command here>"
    }
}

source https://github.com/bower/bower/blob/master/HOOKS.md

like image 28
schurpf Avatar answered Sep 19 '22 07:09

schurpf