Driving LEDs / other small loads with a 74HC06 or similar inverter
As long as you observe the datasheet limits (as you seem to have done) there are no real tricks here. A typical microcontroller may contain thousands to millions of transistors so tend to be fabricated using processes suited to to higher density logic instead of being aimed at high-current / power dissipation.

Those simple gates / drivers might contain in the order of dozens of transistors so use different processes, so if you find a part where the datasheet meets your needs go for it.

Just as a further comment, in high-volume commercial designs sometimes the reason the 'trick' isn't used is that when machine placed the transistors and a few resistors often work out cheaper.