Electron-beam spectroscopy for nanophotonics