The scripts/stylesheets keys in .info and layout.yml files encourages module/theme authors to drop some CSS or js in their folder, add that line, then leave it there.

However #1737148: Explicitly declare all JS dependencies, don't use drupal_add_js means that all js should be registered by hook_library_info() and added via #attached['library']

The two approaches aren't really compatible so this needs figuring out.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

nod_’s picture

nod_’s picture

#1996238: Replace hook_library_info() by *.libraries.yml file Should make it easier for ppl to declare their assets.

nod_’s picture

remove scripts[] from info files and replace it with library[]. Whether it's a bug or a feature, hook_library_info() can be called from template.php just fine.

stylesheets[] can be kept as is, it's totally fair to add a single css file without dependencies. It's highly unlikely for scripts, they will need to depend on jquery, drupal.js 99% of the time.

nod_’s picture

ok that patch doesn't work but it's supposed to add the install-page library on all seven pages. But it doesn't work.

tim.plunkett’s picture

Issue summary: View changes
Issue tags: +beta target

Bump, now that we're focusing so much on libraries and their dependencies, I think this is pretty important

nod_’s picture

Title: Integrate scripts/stylesheets from info/layout files with hook_library_info() » Integrate scripts/stylesheets from info/layout files with libraries
Status: Active » Needs review
FileSize
4.33 KB

Patch works now.

( edit ) and it removes the scripts key from the info file.

Status: Needs review » Needs work

The last submitted patch, 7: core-theme-libraries-1813186-7.patch, failed testing.

nod_’s picture

Status: Needs work » Needs review
FileSize
6.15 KB
1.69 KB

No idea about the color fail.

Status: Needs review » Needs work

The last submitted patch, 9: core-theme-libraries-1813186-9.patch, failed testing.

nod_’s picture

Status: Needs work » Needs review
FileSize
675 bytes
6.12 KB

So the color module only looks into the css files added with stylesheet, not the ones that are in a library.

Probably needs fixing but it's out of scope here.

nod_’s picture

nod_’s picture

Change record draft here: https://drupal.org/node/2228783

Dragan Eror’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
15.31 KB
23.79 KB

I tested this patch and it works really nice...

I created custom theme, in THEMENAME.info.yml I added

libraries:
  - juliette/juliettelib

created THEMENAME.libraries.yml file and added few important lines into it

juliettelib:
  version: 1.x
  js:
    js/test.js: {}
  css:
    theme:
      css/style2.css: {}
  dependencies:
    - core/jquery
    - core/drupal

(See attached images...)

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit 9a8caf4 on 8.x by catch:
    Issue #1813186 by nod_: Integrate scripts/stylesheets from info/layout...
swentel’s picture

FileSize
36.04 KB

Hmmm, the blocks on the left have a block border now, reverting this patch makes it ok again - unless this is the intention of this patch of course ..

  • Commit be94d4e on 8.x by catch:
    Revert "Issue #1813186 by nod_: Integrate scripts/stylesheets from info/...
catch’s picture

Status: Fixed » Needs work

Interesting... reverted for now.

nod_’s picture

Status: Needs work » Needs review
FileSize
6.34 KB
1.95 KB

Before #11 patch:

<style media="all">
@import url("http://drupal8/core/themes/bartik/css/layout.css?n39hoa");
@import url("http://drupal8/core/themes/bartik/css/style.css?n39hoa");
@import url("http://drupal8/core/themes/bartik/css/colors.css?n39hoa");
</style>

After #11 patch:

<style media="all">
@import url("http://drupal8/core/themes/bartik/css/colors.css?n39hoa");
</style>
<style media="all">
@import url("http://drupal8/core/themes/bartik/css/layout.css?n39hoa");
@import url("http://drupal8/core/themes/bartik/css/style.css?n39hoa");
</style>

One can question the need for the library in bartik but it's important enough to have on example in core. so for now just adding the libraries key and not using it until color module is fixed in related issue.

Dragan Eror’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
87.73 KB

Border removed/fixed and patch still works fine with its functionality. Thanks @nod_!

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit 4e5b048 on 8.x by catch:
    Issue #1813186 by nod_: Integrate scripts/stylesheets from info/layout...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.