Counter-Raiding And Rebuilding Under Fire
A raid on your base is also a raid you can raid. Here is how to decide between defending, counter-raiding, and cutting your losses.

When your base is being opened, you have three options and most players never consciously choose between them: hold the base, take the fight outside, or write it off and protect what is left.
Hold when the loot room is still behind real layers and you have angles to shoot from. Go outside when the raiders have committed — they are usually stacked in one place, watching one direction, with their own loot and explosives in a bag or a nearby box. A raid group in the middle of a raid is the least defended it will be all wipe, and their raid base is often thinner than yours. Write it off when the walls between them and your loot are gone; at that point every minute you spend inside is a minute you are not moving the things you can still save.
If you counter-raid, go for the resupply, not the kill. Explosives in a box outside your base are the raid: take them or destroy them and the raid stops whether or not you win a single fight.
Rebuilding is a discipline of its own. Repair in the order that restores cost, not the order that looks tidy: outer shell first, then the layer around the loot, then doors, then anything cosmetic. Do not re-stock the base with everything you own the moment it is sealed — you have just proved where the loot is, and the follow-up raid is more likely than the first one was.
And write down what happened. Which side did they pick, where did they set up, what did it cost them. A base that was raided once and rebuilt the same way is a base that will be raided the same way.