Browserify Bundles in Git Repo

时间:2016-07-11 20:15:12

标签: git browserify

Is it considered bad practice to store an output Browserify bundle in a git repo? I've been doing this for a little while now but I when I try to research the topic I can't find anyone talking about this. Whenever I see instances of people using Browserify, they always talk about using it on their dev server, typically with a build tool like Gulp or Grunt, but they never talk about how they move the bundled code to their production server(s).

I've started running into a lot of trouble with bundles when I'm trying to merge code from a separate branch into my master. The bundles always cause a conflict and it's a pain to to have to fix them. What I'm considering doing now is removing the bundle from my git repo altogether and just building the bundle on my prod server using a git hook script. If there's a better way of going about this though I'd like to hear it.

1 个答案:

答案 0 :(得分:1)

This is considered a bad practice. Some reasons that this is a bad practice are:

  1. It is unnecessary to store the compiled/bundled code in your project, because you can build it later, and this adds bloat to your project.
  2. You may run into frequent merge conflicts (which you are experiencing). Because the end result, depending on what happens in the "build", can be drastically different from build to build, you may find yourself with numerous conflicts.
  3. This also muddies your git history. Instead of having commits which are tied to changes in your source code that are readable, you are always committing a bunch of minified/mangled/built code, which makes looking at the changes made in that commit more difficult.

As far as suggesting how you should best go about this, I think you have the right idea, where you build as part of your deployment process. You should look into using Jenkins if you don't want to have to always manually shell into your server and run the build from the command line. There are other tools such as Capistrano which are also commonly used in conjuction with Jenkins for building/deploying.

Hope this is helpful!