How to attach a library to a specific content type? I wonder how to attach a library to a specific content type. .e.g News. I found the following code from a post and applied the "hook" to the "node" but no idea how to filter by content type. Any idea?

function fluffiness_preprocess_node(&amp;$variables) {
  $variables['#attached']['library'][] = 'fluffiness/cuddly-slider';
}


ref:
https://www.drupal.org/docs/8/theming-drupal-8/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-theme
You can check content type and add libraries like this:

function fluffiness_preprocess_node(&amp;$variables) {
  $node = $variables['node'];
  //check content type
  if ($node-&gt;getType() == 'article') {
    $variables['#attached']['library'][] = 'fluffiness/cuddly-slider'; 
  }
}