Journal Archives About Books Talks
journal

Suppress generated JavaScript on GitHub diffs

Babel generates most of the JavaScript I deploy these days. This makes pull requests a little noisy since I have to skip over the generated output in the dist folder to review the actual source changes in src.

I recently stumbled across this Thoughtbot post that showed how to suppress diffs for certain files on GitHub using a .gitattributes file, and I wondered if it would work for this use case. As it turns out, it does.

To start, create a .gitattributes file in your repository root if you don't already have one and add the following line:

dist/* linguist-generated

Now make a change to something in your src/ folder that will change the generated output in dist/ and push your changes up to a new branch on GitHub.

You'll see something like this:

diff suppression

Diffs for generated JavaScript files are no longer loaded by default, but you can always load them manually if you need to view them.

Here's to a little more efficient code review.

# Posted on