Jan 25, 2021 in Drupal 8

Little snippet to get the current view mode:

function THEMENAME_preprocess_node(&$vars) { 
 if(($node->getType() == 'event') && ($vars['view_mode'] == 'teaser')) {
    // Go further here
  }
}