At the start of The Last Jedi the Resistance is in full retreat. From the opening crawl:
The FIRST ORDER reigns. Having decimated the peaceful Republic, Supreme Leader Snoke now deploys his merciless legions to seize military control of the galaxy.
Only General Leia Organa’s band of RESISTANCE fighters stand against the rising tyranny, certain that Jedi Master Luke Skywalker will return and restore a spark of hope to the fight.
But the Resistance has been exposed. As the First Order speeds toward the rebel base, the brave heroes mount a desperate escape...."
How was the Resistance exposed exactly? What caused them to evacuate?