Ships in SW don't travel at the speed of light. They travel faster. A ship must accelerate to light speed to enter a sub-dimension called hyperspace, where objects can travel faster than light
BUT gravity from the real world is still felt in hyperspace (called a "gravity shadow").
And that's why you never see the lightspeed ram maneuver in Star Wars. Thank you for coming to my TED Talk.