on the route above you can get a ghost type that's immune to everything the lopunny can do. then you lower it's ATK/DEF to have another mon swap in safely to get the kill
I did a bit of grinding before the gym and it made the whole thing a cake walk. basically get around 4 pokemon a few levels higher than the gym pokemon.