Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#21 | Screen Shot 2014-03-31 at 14.31.35.png | 87.73 KB | Dragan Eror |
#20 | interdiff.txt | 1.95 KB | nod_ |
#20 | core-theme-libraries-1813186-20.patch | 6.34 KB | nod_ |
#17 | blocks-border.png | 36.04 KB | swentel |
#14 | juliette.libraries.yml.png | 23.79 KB | Dragan Eror |
Comments
Comment #1
sunClosely related, possibly duplicate of: #1805452: [meta] Asset library declarations, registry, usage, DX, compatibility, documentation
Comment #2
nod_Or this one? #1861676: Remove stylesheets[] and scripts[] .info file property support for modules.
Comment #3
nod_#1996238: Replace hook_library_info() by *.libraries.yml file Should make it easier for ppl to declare their assets.
Comment #4
nod_remove
scripts[]
from info files and replace it withlibrary[]
. 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.
Comment #5
nod_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.
Comment #6
tim.plunkettBump, now that we're focusing so much on libraries and their dependencies, I think this is pretty important
Comment #7
nod_Patch works now.
( edit ) and it removes the
scripts
key from the info file.Comment #9
nod_No idea about the color fail.
Comment #11
nod_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.
Comment #12
nod_Added an issue to color module #2228745: Color module doesn't look for CSS files declared in a library.
Comment #13
nod_Change record draft here: https://drupal.org/node/2228783
Comment #14
Dragan Eror CreditAttribution: Dragan Eror commentedI tested this patch and it works really nice...
I created custom theme, in THEMENAME.info.yml I added
created THEMENAME.libraries.yml file and added few important lines into it
(See attached images...)
Comment #15
catchCommitted/pushed to 8.x, thanks!
Comment #17
swentel CreditAttribution: swentel commentedHmmm, 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 ..
Comment #19
catchInteresting... reverted for now.
Comment #20
nod_Before #11 patch:
After #11 patch:
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.
Comment #21
Dragan Eror CreditAttribution: Dragan Eror commentedBorder removed/fixed and patch still works fine with its functionality. Thanks @nod_!
Comment #22
catchCommitted/pushed to 8.x, thanks!