From 0bfb32b55b4b299064938879dad8c46b5a1a66d0 Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Wed, 26 Nov 2014 10:37:53 +0000
Subject: [PATCH] git commit -m 'Issue #2377397 by Wim Leers, alexpott: Themes
 should use libraries, not individual stylesheets'

---
 .../Drupal/Core/Extension/ThemeHandler.php    | 48 +------------------
 core/lib/Drupal/Core/Theme/ActiveTheme.php    | 17 -------
 .../Drupal/Core/Theme/ThemeInitialization.php | 19 --------
 core/modules/node/node.libraries.yml          |  6 +++
 core/modules/node/src/NodeForm.php            |  2 +
 core/modules/system/system.module             | 11 +----
 .../theme_test/src/ThemeTestController.php    | 10 +---
 .../theme_test/theme_test.libraries.yml       | 10 ++++
 .../test_basetheme/test_basetheme.info.yml    |  7 +--
 .../test_basetheme.libraries.yml              |  7 +++
 .../test_subtheme/test_subtheme.info.yml      |  5 +-
 .../test_subtheme/test_subtheme.libraries.yml |  5 ++
 core/modules/toolbar/toolbar.api.php          |  4 +-
 .../Tests/Core/Extension/ThemeHandlerTest.php | 40 +---------------
 core/themes/bartik/bartik.info.yml            |  2 +-
 core/themes/bartik/bartik.libraries.yml       |  4 +-
 core/themes/seven/seven.info.yml              | 35 +-------------
 core/themes/seven/seven.libraries.yml         | 47 ++++++++++++++++++
 core/themes/seven/seven.theme                 |  2 +-
 core/themes/stark/stark.info.yml              |  5 +-
 core/themes/stark/stark.libraries.yml         |  5 ++
 21 files changed, 102 insertions(+), 189 deletions(-)
 create mode 100644 core/modules/system/tests/modules/theme_test/theme_test.libraries.yml
 create mode 100644 core/modules/system/tests/themes/test_basetheme/test_basetheme.libraries.yml
 create mode 100644 core/modules/system/tests/themes/test_subtheme/test_subtheme.libraries.yml
 create mode 100644 core/themes/stark/stark.libraries.yml

diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php
index 02100fba4f08..8beb1849a344 100644
--- a/core/lib/Drupal/Core/Extension/ThemeHandler.php
+++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php
@@ -396,12 +396,6 @@ public function listInfo() {
    * {@inheritdoc}
    */
   public function addTheme(Extension $theme) {
-    // @todo Remove this 100% unnecessary duplication of properties.
-    foreach ($theme->info['stylesheets'] as $media => $stylesheets) {
-      foreach ($stylesheets as $stylesheet => $path) {
-        $theme->stylesheets[$media][$stylesheet] = $path;
-      }
-    }
     foreach ($theme->info['libraries'] as $library => $name) {
       $theme->libraries[$library] = $name;
     }
@@ -471,7 +465,6 @@ public function rebuildThemeData() {
       'features' => $this->defaultFeatures,
       'screenshot' => 'screenshot.png',
       'php' => DRUPAL_MINIMUM_PHP,
-      'stylesheets' => array(),
       'libraries' => array(),
     );
 
@@ -507,11 +500,9 @@ public function rebuildThemeData() {
         $theme->prefix = $engines[$engine]->getName();
       }
 
-      // Prefix stylesheets and screenshot with theme path.
-      $path = $theme->getPath();
-      $theme->info['stylesheets'] = $this->themeInfoPrefixPath($theme->info['stylesheets'], $path);
+      // Prefix screenshot with theme path.
       if (!empty($theme->info['screenshot'])) {
-        $theme->info['screenshot'] = $path . '/' . $theme->info['screenshot'];
+        $theme->info['screenshot'] = $theme->getPath() . '/' . $theme->info['screenshot'];
       }
 
       $files[$key] = $theme->getPathname();
@@ -555,41 +546,6 @@ public function rebuildThemeData() {
     return $themes;
   }
 
-  /**
-   * Prefixes all values in an .info.yml file array with a given path.
-   *
-   * This helper function is mainly used to prefix all array values of an
-   * .info.yml file property with a single given path (to the module or theme);
-   * e.g., to prefix all values of the 'stylesheets' properties
-   * with the file path to the defining module/theme.
-   *
-   * @param array $info
-   *   A nested array of data of an .info.yml file to be processed.
-   * @param string $path
-   *   A file path to prepend to each value in $info.
-   *
-   * @return array
-   *   The $info array with prefixed values.
-   *
-   * @see _system_rebuild_module_data()
-   * @see self::rebuildThemeData()
-   */
-  protected function themeInfoPrefixPath(array $info, $path) {
-    foreach ($info as $key => $value) {
-      // Recurse into nested values until we reach the deepest level.
-      if (is_array($value)) {
-        $info[$key] = $this->themeInfoPrefixPath($info[$key], $path);
-      }
-      // Unset the original value's key and set the new value with prefix, using
-      // the original value as key, so original values can still be looked up.
-      else {
-        unset($info[$key]);
-        $info[$value] = $path . '/' . $value;
-      }
-    }
-    return $info;
-  }
-
   /**
    * {@inheritdoc}
    */
diff --git a/core/lib/Drupal/Core/Theme/ActiveTheme.php b/core/lib/Drupal/Core/Theme/ActiveTheme.php
index b0940dc9bcf1..dfccdc40a38c 100644
--- a/core/lib/Drupal/Core/Theme/ActiveTheme.php
+++ b/core/lib/Drupal/Core/Theme/ActiveTheme.php
@@ -59,13 +59,6 @@ class ActiveTheme {
    */
   protected $extension;
 
-  /**
-   * The provided stylesheet of the theme.
-   *
-   * @var array
-   */
-  protected $styleSheets;
-
   /**
    * The stylesheets which are set to be removed by the theme.
    *
@@ -98,7 +91,6 @@ public function __construct(array $values) {
     $this->path = $values['path'];
     $this->engine = $values['engine'];
     $this->owner = $values['owner'];
-    $this->styleSheets = $values['stylesheets'];
     $this->styleSheetsRemove = $values['stylesheets_remove'];
     $this->styleSheetsOverride = $values['stylesheets_override'];
     $this->libraries = $values['libraries'];
@@ -162,15 +154,6 @@ public function getLibraries() {
     return $this->libraries;
   }
 
-  /**
-   * Returns the stylesheets provided by the theme.
-   *
-   * @return mixed
-   */
-  public function getStyleSheets() {
-    return $this->styleSheets;
-  }
-
   /**
    * Returns the overridden stylesheets by the theme.
    *
diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
index bbe5cc763610..0dbd0c662fee 100644
--- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php
+++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
@@ -154,22 +154,13 @@ public function getActiveTheme(Extension $theme, array $base_themes = []) {
     // Prepare stylesheets from this theme as well as all ancestor themes.
     // We work it this way so that we can have child themes override parent
     // theme stylesheets easily.
-    $values['stylesheets'] = array();
     // CSS file basenames to override, pointing to the final, overridden filepath.
     $values['stylesheets_override'] = array();
     // CSS file basenames to remove.
     $values['stylesheets_remove'] = array();
 
     // Grab stylesheets from base theme.
-    $final_stylesheets = array();
     foreach ($base_themes as $base) {
-      if (!empty($base->stylesheets)) {
-        foreach ($base->stylesheets as $media => $stylesheets) {
-          foreach ($stylesheets as $name => $stylesheet) {
-            $final_stylesheets[$media][$name] = $stylesheet;
-          }
-        }
-      }
       $base_theme_path = $base->getPath();
       if (!empty($base->info['stylesheets-remove'])) {
         foreach ($base->info['stylesheets-remove'] as $basename) {
@@ -185,13 +176,6 @@ public function getActiveTheme(Extension $theme, array $base_themes = []) {
     }
 
     // Add stylesheets used by this theme.
-    if (!empty($theme->stylesheets)) {
-      foreach ($theme->stylesheets as $media => $stylesheets) {
-        foreach ($stylesheets as $name => $stylesheet) {
-          $final_stylesheets[$media][$name] = $stylesheet;
-        }
-      }
-    }
     if (!empty($theme->info['stylesheets-remove'])) {
       foreach ($theme->info['stylesheets-remove'] as $basename) {
         $values['stylesheets_remove'][$basename] = $theme_path . '/' . $basename;
@@ -212,9 +196,6 @@ public function getActiveTheme(Extension $theme, array $base_themes = []) {
       }
     }
 
-    // And now add the stylesheets properly.
-    $values['stylesheets'] = $final_stylesheets;
-
     // Do basically the same as the above for libraries
     $values['libraries'] = array();
 
diff --git a/core/modules/node/node.libraries.yml b/core/modules/node/node.libraries.yml
index 231687e30644..2b3d80d2ac49 100644
--- a/core/modules/node/node.libraries.yml
+++ b/core/modules/node/node.libraries.yml
@@ -30,6 +30,12 @@ drupal.content_types:
     - core/drupal
     - core/drupal.form
 
+form:
+  version: VERSION
+  css:
+    layout:
+      css/node.module.css: {}
+
 drupal.node.admin:
   version: VERSION
   css:
diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php
index 7f9ef847c786..7e0a854ce595 100644
--- a/core/modules/node/src/NodeForm.php
+++ b/core/modules/node/src/NodeForm.php
@@ -205,6 +205,8 @@ public function form(array $form, FormStateInterface $form_state) {
       $form['sticky']['#group'] = 'options';
     }
 
+    $form['#attached']['library'][] = 'node/form';
+
     return $form;
   }
 
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 51aeebb1a81e..32193beedecb 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -528,20 +528,11 @@ function system_page_attachments(array &$page) {
     $page['#attached']['library'][] = 'system/admin';
   }
 
-  // Attach libraries and CSS used by this theme.
+  // Attach libraries used by this theme.
   $active_theme = \Drupal::theme()->getActiveTheme();
   foreach ($active_theme->getLibraries() as $library) {
     $page['#attached']['library'][] = $library;
   }
-  foreach ($active_theme->getStyleSheets() as $media => $stylesheets) {
-    foreach ($stylesheets as $stylesheet) {
-      $page['#attached']['css'][$stylesheet] = array(
-        'group' => CSS_AGGREGATE_THEME,
-        'every_page' => TRUE,
-        'media' => $media
-      );
-    }
-  }
 
   // Attach favicon.
   if (theme_get_setting('features.favicon')) {
diff --git a/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php b/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php
index fb8e1f9871d4..cf42211b608d 100644
--- a/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php
+++ b/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php
@@ -34,16 +34,10 @@ public function functionTemplateOverridden() {
    *   A render array containing custom stylesheets.
    */
   public function testInfoStylesheets() {
-    $path = drupal_get_path('module', 'theme_test');
     return array(
       '#attached' => array(
-        'css' => array(
-          "$path/css/base-override.css",
-          "$path/css/base-override.sub-remove.css",
-          "$path/css/base-remove.css",
-          "$path/css/base-remove.sub-override.css",
-          "$path/css/sub-override.css",
-          "$path/css/sub-remove.css",
+        'library' => array(
+          'theme_test/theme_stylesheets_override_and_remove_test',
         ),
       ),
     );
diff --git a/core/modules/system/tests/modules/theme_test/theme_test.libraries.yml b/core/modules/system/tests/modules/theme_test/theme_test.libraries.yml
new file mode 100644
index 000000000000..b08521e1b75f
--- /dev/null
+++ b/core/modules/system/tests/modules/theme_test/theme_test.libraries.yml
@@ -0,0 +1,10 @@
+theme_stylesheets_override_and_remove_test:
+  version: VERSION
+  css:
+    base:
+      css/base-override.css: {}
+      css/base-override.sub-remove.css: {}
+      css/base-remove.css: {}
+      css/base-remove.sub-override.css: {}
+      css/sub-override.css: {}
+      css/sub-remove.css: {}
diff --git a/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml b/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml
index 2edc8234d689..6a95a1c92d5f 100644
--- a/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml
+++ b/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml
@@ -3,11 +3,8 @@ type: theme
 description: 'Test theme which acts as a base theme for other test subthemes.'
 version: VERSION
 core: 8.x
-stylesheets:
-  all:
-    - base-add.css
-    - base-add.sub-override.css
-    - base-add.sub-remove.css
+libraries:
+  - test_basetheme/global-styling
 stylesheets-override:
   - base-override.css
   - base-override.sub-remove.css
diff --git a/core/modules/system/tests/themes/test_basetheme/test_basetheme.libraries.yml b/core/modules/system/tests/themes/test_basetheme/test_basetheme.libraries.yml
new file mode 100644
index 000000000000..1c72d30b6a07
--- /dev/null
+++ b/core/modules/system/tests/themes/test_basetheme/test_basetheme.libraries.yml
@@ -0,0 +1,7 @@
+global-styling:
+  version: VERSION
+  css:
+    base:
+      base-add.css: {}
+      base-add.sub-override.css: {}
+      base-add.sub-remove.css: {}
diff --git a/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml b/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml
index cdcd8f0855e7..921f2f04149b 100644
--- a/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml
+++ b/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml
@@ -4,9 +4,8 @@ description: 'Test theme which uses test_basetheme as the base theme.'
 version: VERSION
 core: 8.x
 base theme: test_basetheme
-stylesheets:
-  all:
-    - css/sub-add.css
+libraries:
+  - test_subtheme/global-styling
 stylesheets-override:
   - css/sub-override.css
   - css/base-add.sub-override.css
diff --git a/core/modules/system/tests/themes/test_subtheme/test_subtheme.libraries.yml b/core/modules/system/tests/themes/test_subtheme/test_subtheme.libraries.yml
new file mode 100644
index 000000000000..efce7aec8494
--- /dev/null
+++ b/core/modules/system/tests/themes/test_subtheme/test_subtheme.libraries.yml
@@ -0,0 +1,5 @@
+global-styling:
+  version: VERSION
+  css:
+    base:
+      css/sub-add.css: {}
diff --git a/core/modules/toolbar/toolbar.api.php b/core/modules/toolbar/toolbar.api.php
index bce69aeae66a..5e9dd39630c0 100644
--- a/core/modules/toolbar/toolbar.api.php
+++ b/core/modules/toolbar/toolbar.api.php
@@ -60,8 +60,8 @@ function hook_toolbar() {
     '#weight' => 200,
     // Custom CSS, JS or a library can be associated with the toolbar item.
     '#attached' => array(
-      'css' => array(
-        drupal_get_path('module', 'search') . '/css/search.base.css',
+      'library' => array(
+        'search/global',
       ),
     ),
   );
diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
index 5dba9dbed86e..0a58e81047c3 100644
--- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
@@ -170,45 +170,7 @@ public function testRebuildThemeData() {
     $this->assertEquals('twig', $info->prefix);
 
     $this->assertEquals('twig', $info->info['engine']);
-    $this->assertEquals(array(), $info->info['libraries']);
-
-    // Ensure that the css paths are set with the proper prefix.
-    $this->assertEquals(array(
-      'screen' => array(
-        'css/base/elements.css' => $this->root . '/core/themes/seven/css/base/elements.css',
-        'css/base/typography.css' => $this->root . '/core/themes/seven/css/base/typography.css',
-        'css/components/admin-list.css' => $this->root . '/core/themes/seven/css/components/admin-list.css',
-        'css/components/admin-options.css' => $this->root . '/core/themes/seven/css/components/admin-options.css',
-        'css/components/admin-panel.css' => $this->root . '/core/themes/seven/css/components/admin-panel.css',
-        'css/components/block-recent-content.css' => $this->root . '/core/themes/seven/css/components/block-recent-content.css',
-        'css/components/content-header.css' => $this->root . '/core/themes/seven/css/components/content-header.css',
-        'css/components/breadcrumb.css' => $this->root . '/core/themes/seven/css/components/breadcrumb.css',
-        'css/components/buttons.css' => $this->root . '/core/themes/seven/css/components/buttons.css',
-        'css/components/buttons.theme.css' => $this->root . '/core/themes/seven/css/components/buttons.theme.css',
-        'css/components/comments.css' => $this->root . '/core/themes/seven/css/components/comments.css',
-        'css/components/messages.css' => $this->root . '/core/themes/seven/css/components/messages.css',
-        'css/components/dropbutton.component.css' => $this->root . '/core/themes/seven/css/components/dropbutton.component.css',
-        'css/components/entity-meta.css' => $this->root . '/core/themes/seven/css/components/entity-meta.css',
-        'css/components/field-ui.css' => $this->root . '/core/themes/seven/css/components/field-ui.css',
-        'css/components/form.css' => $this->root . '/core/themes/seven/css/components/form.css',
-        'css/components/help.css' => $this->root . '/core/themes/seven/css/components/help.css',
-        'css/components/menus-and-lists.css' => $this->root . '/core/themes/seven/css/components/menus-and-lists.css',
-        'css/components/modules-page.css' => $this->root . '/core/themes/seven/css/components/modules-page.css',
-        'css/components/node.css' => $this->root . '/core/themes/seven/css/components/node.css',
-        'css/components/page-title.css' => $this->root . '/core/themes/seven/css/components/page-title.css',
-        'css/components/pager.css' => $this->root . '/core/themes/seven/css/components/pager.css',
-        'css/components/skip-link.css' => $this->root . '/core/themes/seven/css/components/skip-link.css',
-        'css/components/tables.css' => $this->root . '/core/themes/seven/css/components/tables.css',
-        'css/components/tabs.css' => $this->root . '/core/themes/seven/css/components/tabs.css',
-        'css/components/tour.theme.css' => $this->root . '/core/themes/seven/css/components/tour.theme.css',
-        'css/components/update-status.css' => $this->root . '/core/themes/seven/css/components/update-status.css',
-        'css/components/views-ui.css' => $this->root . '/core/themes/seven/css/components/views-ui.css',
-        'css/layout/layout.css' => $this->root . '/core/themes/seven/css/layout/layout.css',
-        'css/layout/node-add.css' => $this->root . '/core/themes/seven/css/layout/node-add.css',
-        'css/theme/appearance-page.css' => $this->root . '/core/themes/seven/css/theme/appearance-page.css',
-      ),
-    ), $info->info['stylesheets']);
-    $this->assertEquals($this->root . '/core/themes/seven/screenshot.png', $info->info['screenshot']);
+    $this->assertEquals(array('seven/global-styling'), $info->info['libraries']);
   }
 
   /**
diff --git a/core/themes/bartik/bartik.info.yml b/core/themes/bartik/bartik.info.yml
index 22e62b47d834..36d9c2588038 100644
--- a/core/themes/bartik/bartik.info.yml
+++ b/core/themes/bartik/bartik.info.yml
@@ -6,7 +6,7 @@ package: Core
 version: VERSION
 core: 8.x
 libraries:
-  - bartik/base
+  - bartik/global-styling
 ckeditor_stylesheets:
   - css/ckeditor-iframe.css
 regions:
diff --git a/core/themes/bartik/bartik.libraries.yml b/core/themes/bartik/bartik.libraries.yml
index 6866d6b85822..c1b0f391f3c0 100644
--- a/core/themes/bartik/bartik.libraries.yml
+++ b/core/themes/bartik/bartik.libraries.yml
@@ -1,4 +1,4 @@
-base:
+global-styling:
   version: VERSION
   css:
     theme:
@@ -14,4 +14,4 @@ maintenance_page:
       css/maintenance-page.css: {}
   dependencies:
     - system/maintenance
-    - bartik/base
+    - bartik/global-styling
diff --git a/core/themes/seven/seven.info.yml b/core/themes/seven/seven.info.yml
index 1277db9de980..8616b6dbc979 100644
--- a/core/themes/seven/seven.info.yml
+++ b/core/themes/seven/seven.info.yml
@@ -7,39 +7,8 @@ tags: 'multi-column, fluid, responsive, sans-serif, accessible'
 package: Core
 version: VERSION
 core: 8.x
-stylesheets:
-  screen:
-    - css/base/elements.css
-    - css/base/typography.css
-    - css/components/admin-list.css
-    - css/components/admin-options.css
-    - css/components/admin-panel.css
-    - css/components/block-recent-content.css
-    - css/components/content-header.css
-    - css/components/breadcrumb.css
-    - css/components/buttons.css
-    - css/components/buttons.theme.css
-    - css/components/comments.css
-    - css/components/messages.css
-    - css/components/dropbutton.component.css
-    - css/components/entity-meta.css
-    - css/components/field-ui.css
-    - css/components/form.css
-    - css/components/help.css
-    - css/components/menus-and-lists.css
-    - css/components/modules-page.css
-    - css/components/node.css
-    - css/components/page-title.css
-    - css/components/pager.css
-    - css/components/skip-link.css
-    - css/components/tables.css
-    - css/components/tabs.css
-    - css/components/tour.theme.css
-    - css/components/update-status.css
-    - css/components/views-ui.css
-    - css/layout/layout.css
-    - css/layout/node-add.css
-    - css/theme/appearance-page.css
+libraries:
+ - seven/global-styling
 stylesheets-override:
   - css/components/vertical-tabs.css
   - css/components/jquery.ui.theme.css
diff --git a/core/themes/seven/seven.libraries.yml b/core/themes/seven/seven.libraries.yml
index a79487161cdf..478f9923ae72 100644
--- a/core/themes/seven/seven.libraries.yml
+++ b/core/themes/seven/seven.libraries.yml
@@ -1,3 +1,49 @@
+global-styling:
+  version: VERSION
+  css:
+    base:
+      css/base/elements.css: {}
+      css/base/typography.css: {}
+    component:
+      css/components/admin-list.css: {}
+      css/components/admin-options.css: {}
+      css/components/admin-panel.css: {}
+      css/components/block-recent-content.css: {}
+      css/components/content-header.css: {}
+      css/components/breadcrumb.css: {}
+      css/components/buttons.css: {}
+      css/components/buttons.theme.css: {}
+      css/components/comments.css: {}
+      css/components/messages.css: {}
+      css/components/dropbutton.component.css: {}
+      css/components/entity-meta.css: {}
+      css/components/field-ui.css: {}
+      css/components/form.css: {}
+      css/components/help.css: {}
+      css/components/menus-and-lists.css: {}
+      css/components/modules-page.css: {}
+      css/components/node.css: {}
+      css/components/page-title.css: {}
+      css/components/pager.css: {}
+      css/components/skip-link.css: {}
+      css/components/tables.css: {}
+      css/components/tabs.css: {}
+      css/components/tour.theme.css: {}
+      css/components/update-status.css: {}
+      css/components/views-ui.css: {}
+    layout:
+      css/layout/layout.css: {}
+    theme:
+      css/theme/appearance-page.css: {}
+
+node-form:
+  version: VERSION
+  css:
+    layout:
+      css/layout/node-add.css: {}
+  dependencies:
+    - node/form
+
 maintenance-page:
   version: VERSION
   js:
@@ -7,6 +53,7 @@ maintenance-page:
       css/theme/maintenance-page.css: {}
   dependencies:
     - system/maintenance
+    - seven/global-styling
 
 install-page:
   version: VERSION
diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme
index ada5da22fcbc..b5f85c3781e6 100644
--- a/core/themes/seven/seven.theme
+++ b/core/themes/seven/seven.theme
@@ -167,7 +167,7 @@ function seven_form_node_form_alter(&$form, FormStateInterface $form_state) {
   $node = $form_state->getFormObject()->getEntity();
 
   $form['#theme'] = array('node_edit_form');
-  $form['#attached']['css'][] = drupal_get_path('module', 'node') . '/css/node.module.css';
+  $form['#attached']['library'][] = 'seven/node-form';
 
   $form['advanced']['#type'] = 'container';
   $is_new = !$node->isNew() ? format_date($node->getChangedTime(), 'short') : t('Not saved yet');
diff --git a/core/themes/stark/stark.info.yml b/core/themes/stark/stark.info.yml
index 6ce7cc68308d..bbb16c6ea671 100644
--- a/core/themes/stark/stark.info.yml
+++ b/core/themes/stark/stark.info.yml
@@ -4,8 +4,7 @@ description: 'An intentionally plain theme with almost no styling to demonstrate
 package: Core
 version: VERSION
 core: 8.x
-stylesheets:
-  all:
-    - css/layout.css
+libraries:
+  - stark/global-styling
 stylesheets-remove:
   - normalize.css
diff --git a/core/themes/stark/stark.libraries.yml b/core/themes/stark/stark.libraries.yml
new file mode 100644
index 000000000000..765514724052
--- /dev/null
+++ b/core/themes/stark/stark.libraries.yml
@@ -0,0 +1,5 @@
+global-styling:
+  version: VERSION
+  css:
+    base:
+      css/layout.css: {}
-- 
GitLab