Monthar
Deity
You might want to double check this before trying it. I don't know about post patch, but I know prepatch when I built barracks in all cities then built the military national wonder the wonder got destroyed when I sold one of my barracks. In a later game I built it again, but the wonder also got destroyed when I founded a new city. So unless the patch changed something you should hold off on building national wonders until after you Rex.
If you were still in the process of building it when you annexed or built a city, it immediately stops building it. I have never seen a national wonder get destroyed because I built/annexed a new city after it was completed, nor from selling the buildings required to build it.
See attached screenshot and saved game for proof. In these it's just the National College (reqs libraries) and National Epic (reqs monuments) in the capital. I built these two before building my first settler in this game. Also I sold the library and monument and ran one more turn to get the attached saved game file as further proof.
Spoiler :
I have now restarted that game to build the barracks and heroic epic then sell the barracks just to get you more proof.
Edit: Here's the screenshot and save with the Heroic Epic after selling the barracks.
Spoiler :
This is from a post-patch game. However, pre-patch I would build national wonders before expanding too far (just the capital or just the first wave of settlers) and didn't lose them from having new cities without their prereq building. I didn't lose the Heroic Epic when I sold the barracks pre-patch.