The site on the Glynneath Business Park is already home to a McDonalds restaurant, but developers Waterstone Estates Limited wanted to expand the operation. The firm proposed a petrol filling station and kiosk, a "drive-thru" coffee shop, a pub/restaurant, car parking and landscaping.
Planning permission was refused by a government inspector in April, but the company mounted a legal challenge to the decision.
Dismissing Waterstone's arguments, however, Mr Justice Fraser last week said he could detect nothing "irrational" in the inspector's ruling.
The inspector had found that the project fell foul of planning policies that restrict new developments outside the defined limits of existing settlements. The inspector also expressed concerns that the retail elements of the scheme might harm the "vitality and viability" of Glynneath town centre.
The judge said the inspector was entitled to find that an alternative site on Park Avenue was "preferable in retail terms".
There was nothing "procedurally unfair" in her handling of the case and there was no flaw in her conclusion that the project would conflict with retail policies in the local development plan, the judge held.
Also rejected were Waterstone's arguments that the scheme was an "infrastructure" project exempted from restrictions on out-of-town retail developments.
The judge said: "It is difficult to see how the kiosk, drive-thru coffee shop, pub/restaurant, access, parking and associated works could fall within the exception as being 'associated with infrastructure'."
Waterstone's judicial review application was dismissed and the inspector's decision upheld.
Waterstone Estates Limited v Welsh Ministers. Case Number: CO/2369/2017