FYI, with the release of ArcGIS Enterprise 10.5.1, Web AppBuilder embedded in Portal for ArcGIS now supports custom widgets. Please see this blog for more details,
Web AppBuilder for ArcGIS now supports Custom Widgets in ArcGIS Enterprise 10.5.1 | ArcGIS Blog
Hope this helps,