Why is domain name resolution slow in Sierra
I assume you already executed all usually proposed mDSNResponder tasks to reset it, clear caches etc.

.dev is a proper "New gTLDs" since 2014. Probably you are using Google Chrome to access your site(s) which often uses its own DNS query service. The flaky name resolution management in OS X as well as the Google Chrome "service" (which both seem to ignore /etc/hosts entries sometimes and then fail to resolve a real firstdomain.dev in the WAN) suggest to simply use another TLD like .development, .devhome or .devwork.

And/or set up dnsmasq with homebrew and use localhost/127.0.0.1 as only DNS server in your network preferences. Setup proper IP addresses instead of a lot of 127.0.0.1 IP-addresses in the config files.