Remove classes in hook_preprocess_block In Drupal 8 I'm struggling to remove classes from a given block. Here's a quick snippet from a preprocess function:

function mytheme_preprocess_block(&amp;$vars) {
  $block_classes = array(
    'block_id' =&gt; array('custom-class'),
  );
  $id = $vars['elements']['#id'];
  if (isset($block_classes[$id])) {
    $vars['attributes']['class'] = $block_classes[$id];
  }
  return $vars;
}


Interestingly this works, and adds custom-class to the block, but even though it is overriding the existing class array, all the default Drupal classes are still added (later on maybe?). I know that I can remove classes in twig with {{ attributes.removeClass('class-to-remove') }}, but ideally I would like to have a preprocess function that doesn't require exposing more template files.
You can't do that. You can see node and file template. Unless, in your theme you set

base theme: stable 


or when you don't define a base theme.