How easy is it to port Discourse community to custom webapp later?

It depends on what “port the community to a custom app later” means.

If you want to migrate away from Discourse to a custom-made database+backend+frontend+etc, a data migration is the way.

If you want to keep using the data and backend layers of Discourse, using it as a headless service and writing a new frontend consuming the existing APIs, that’s also possible and has been done before.

One thing to consider, though, is that Discourse is HUGE, like REALLY HUGE. The chat feature for example is a big undertake, and it’s just a tiny little fraction of what Discourse is.

Rewriting these UIs will certainly feel like reinventing the wheel, and once you have all these features taken for granted on your community it will be hard to migrate to a custom app missing them.