How to preprocess scene on build?

Is there a way to PREPROCESS scene on building project, to remove specific objects?

I have scene objects with big meshes generated at runtime and in editor. When I build project, it takes few minutes for Unity to build (Building assets for scene). And I dont need meshes to be saved with the scene, because they are generated at runtime.

I was expecting something like OnSceneBuild callback…

Answer to myself two years later: use HideFlags.

And what I was looking for initially is [PostProcessSceneAttribute] as was suggested in the comments. Thank you.

For those still wondering about this few years later, there is an interface you should implement for that very thing:

IProcessSceneWithReport