In 5.21 this is a setting in project settings, 2nd tab (Model).
There is a radio button just underneath the enable page template option, this option 'Enable widget bundling' does this. However I'm not sure when this feature was introduced. I think this was introduced either in .20 or .21
I'm not aware if this is possible prior to 5.21.
Jasper is correct, this was introduced in 5.21 and not possible prior. Have a look at the changelog under 'fixes': 'Added project setting "Enable widget bundling" to always bundle custom widgets when deploying. (Ticket 384320)'