I've learned that I need to back up the app I'm working on before I make any changes that will require me to press the SAVE button. That's because it will occasionally throw away all the widgets in the app and delete their code.
Today, I started up web appbuilder. Opened up my app and added a widget to it, then pressed save.
It just happened deleted code again. Here's what the relevant console log shows, less the date time stamps and the true server and custom widget names:
...................Repository items refreshed.................
[INFO] server - Portal https://myUrl.com/arcgis uses web-tier authorization.
[INFO] server - Set isXT = true; /webappbuilder/stemapp/env.js
[INFO] server - Set isXT = true; /webappbuilder/apps/2/env.js
[DEBUG] utils - copy D:\esri_webappbuilder_2\client\stemapp\widgets\myCustomWidget3
[INFO] app - remove widget AddData from app 2
[INFO] app - remove widget BasemapGallery from app 2
[INFO] app - remove widget Measurement from app 2
[INFO] app - remove widget myCustomWidget1 from app 2
[INFO] app - remove widget myCustomWidget2 from app 2
[INFO] app - remove widget myCustomWidget3 from app 2
[INFO] server - Portal https://myUrl.com/arcgis uses web-tier authorization.
[INFO] server - Set isXT = true; /webappbuilder/stemap/env.js
Because of this behavior, I've learned to back up the app before I add a widget or change the basemap, etc. This is an especially pernicious defect because if you're in the midst of writing a custom widget in your app, it literally deletes the widget code from the app!