I have a record collection and a cd collection. It was not the same. So many CDs of older music sound bad on CD. Recordings made during the CD era sound fine though, but I'm not an audiophile. Maybe the "loudness wars" are a complaint for some.
The loudness war (in the usual sense of the phrase) on CDs was to not seem weak against other releases. The loudness war (if I may use that phrase very liberally now) on analog media is to not seem weak against hiss and surface noise. The desire to compress and limit dynamic range does exist for both, but for these different reasons.
However, a huge difference is that on CDs you're up against a fixed maximum (0 dBFS) so all peaks are equal, which is fatiguing; on vinyl you're up against the adjacent groove, so your maximum amplitude any given moment depends on the amplitude of things in the recent past and near future! Ways to optimize for this are prevalent, amazingly, and the result is less fatiguing.
There was a stretch of time between when specific mastering for CDs started and before the loudness war kicked in. Plenty of time for good recordings to happen.
It is partly the medium's fault. A lot of the sins of CD/digital mastering wont fly on vinyl because there's physical constraints around what you can literally press into the record groove.
Classical labels were recording digitally even before CD players existed, to avoid the generation loss of recording to tape before transferring to vinyl. These recordings were later released on CD and mostly sound great.
Dire Straits - Brothers In Arms (1985 release, first CD to sell over a million copies) also sounds great, and IMO better than most modern releases.
Some early CDs were recorded using pre-emphasis, similar to the RIAA equalization used with vinyl records. CDs using this have a flag set in the metadata to tell the player to apply a matching de-emphasis filter. I sometimes see people blaming digital production for early CDs sounding "thin". I think it's more likely they heard rips of CDs using pre-emphasis that didn't have the proper de-emphasis applied.
An average CD from the 80s sounds better than an average CD from any other era, because it pre-dates the loudness war, and because it's intended to be played on a good home stereo (which if you were buying CDs back then you could probably afford).