On an episode of Ask This Old House, they replaced a vanity that had a GFCI mounted in the side of it. It was the only outlet in the bathroom and the homeowner didn't want to lose it.
After installing a new in-stock Borg vanity, Rich cut a hole in the thin side wall of the vanity and mounted the original metal receptacle box using Madison hangers.
It didn't really seem like the most secure installation considering the thickness of the vanity side panel.
Does that type of installation meet code?