How to limit preprocess functions base on a theme?
You can check theme active with function:

&lt;?php

$active = \Drupal::theme()-&gt;getActiveTheme()-&gt;getName();


Get list all themes with:

&lt;?php

$themes = \Drupal::service('theme_handler')-&gt;listInfo()