If you are using systemd-resolved then you can use *.localhost without editing /etc/hosts (whole domain should resolve to loopback address).
If you are using systemd-resolved then you can use *.localhost without editing /etc/hosts (whole domain should resolve to loopback address).