I've done it. It was cord and plug connected and plugged into a GFCI receptacle, since it was in the bathroom cabinet. It's up to the homeowner to not burn their house down doing something I would call "stupid."
It looked pretty sweet when I was done, despite the fancy custom drawer being almost
exactly the same height as the receptacle coverplate was wide.