We present a moderate-deviations principle around non-degenerate attractors of the empirical measure of random variables distributed according to a mean-field Gibbs measure. We state a result for a large class of densities of the Gibbs measure. This result is an application of a rank-dependent moderate-deviations principle for a collection of $U$-empirical measures. The results are applied for diffusion processes with mean-field interaction leading to a McKean--Vlasov limit, and to the Curie--Weiss model.