A South Yorkshire school once criticised by parents for being too small will undergo a £2m expansion.