How to author a bower package?

42 Views Asked by At

We have created successfully a bower package and it is working great with Subversion and private-bower.

The issue I am facing now, is that we need also the generated files to be commited into (Subversion or Git) to work properly for

bower install or bower update

Now every build creates a conflict in the local copy of the repository.

My question is, can I tell bower to do a post install or post update command to execute a build? In my case it should run a grunt task to build the files locally.

Just wondering if bower is not capable of doing such steps to avoid conflicts on the git/svn repository? Or what is the suggested way to avoid merge conflicts?

1

There are 1 best solutions below

1
topheman On

There are postinstall hooks in bower https://github.com/bower/bower/blob/master/HOOKS.md but you can't rely on it as a package provider (they're designed to be used by the developpers who install your package)

For your situation, teams that provide bower packages that require a build step have two main workflows:

  • The repo tied to the bower registry is the source repo. Sources & build files are in it (like bootstrap). So when you bower install, you retrieve the whole repo with all the sources, build routines, etc ... which can be quite big. That's your case currently.
  • The repo tied to the bower registry and the repo holding the sources are two different repos (like angular):
    • Your build directory is in fact the repo tied to bower
    • Each time you make a new release, you build and then commit from that repo.

If you're having versionning problems, maybe you should switch to the second workflow (which will also let you clean all the unecessary files like build routines).