This weekend, I came across an interesting article regarding building a static Bitbucket add-on comprising just HTML, CSS and JS. Generally, add-ons for Atlassian products are built using the connect framework which is based on REST APIs and web hooks. However, it’s also possible to build some add-ons that do not have any server component.
From the README file, it looks like the author hosted the example code on firebase. However, another way to host such add-ons is on Github. Github has had static file hosting support for some time. I used this approach for hosting my version of this example. The biggest convenience is that there is no separate deployment step required. Just pushing the code to Github updates the add-on!
I looked online for an ant library that could accomplish this and came across one that was almost exactly what I was looking for. It could minify JS files using YUI Compressor but lacked a couple of features I required. So, I went through the library’s source code and added the following features
Minification option for CSS files
Option to delete original source files after minification
Since other people might want to use these additional features, I’ve made the modified library open source on GitHub:
The README file describes the available options and how to use them. There’s also an example folder with a working ant project for JS/CSS minification. My code is based on the yui-compressor-ant-task hosted on google code.