How to minify/optimise Javascript on Magento 2?

In the end we used a gulp script we wrote ourselves that looks for every javascript file and minifies it. Looks like this is the only way to do it for now without dealing with the bugs the built in magento config option has.

This was our eventual gulp file solution: https://gist.github.com/lewisp6/b7c50b4d82ef4d3d5d6dc888e8d1bdba


I think all that you need is enable "Enable JavaScript Bundling" and "Minify JavaScript Files" options in system configuration on website level in System Configuration > ADVANCED > Developer > JavaScript Settings section and redeploy static content