We find necessary and sufficient conditions for compactness of Sobolev imbeddings involving rearrangement-invariant norms.