Closed (fixed)
Project:
Drupal core
Version:
8.0.0-rc3
Component:
asset library system
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
7 Nov 2015 at 04:11 UTC
Updated:
9 Nov 2015 at 17:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dawehnerDo you point providing a code example?
Comment #3
hatuhay commentedComplete code on: https://www.drupal.org/project/bootstrap_library
bootstrap_library.libraries.yml
bootstrap_library.module
Comment #4
wim leersis far too vague. Please provide proper steps to reproduce.
Also, this makes no sense at all. This is from a Drupal 7 era where we depended on global state. Just delete this.
… if you do this, then you need to associate the appropriate cache tags and cache contexts, so that Drupal knows about these variations. See https://www.drupal.org/developing/api/8/cache/tags + https://www.drupal.org/developing/api/8/cache/contexts.
Similarly here, you need to associate the cacheability metadata of that configuration.
This should implement
hook_library_info_build()instead.Comment #5
hatuhay commentedThanks for the quick response!!!
To reproduce the problem:
Install bootstrap_library on a clean Drupal 8 installation. Use DEV version http://ftp.drupal.org/files/projects/bootstrap_library-8.x-1.x-dev.tar.gz
Install local bootstrap on /libraries/bootstrap folder
There are three options for loading bootstrap libraries:
First two local versions load with no problem.
But CDN version does not load, it is not added to the javascript pool.
Tried two options, neither worked:
Comment #6
hatuhay commentedComment #7
droplet commentedhook_library_info_build doesn't work for me either. But hook_library_info_alter does the job. It declared test case for hook_library_info_build / hook_library_info_alter but doesn't verify test result?
https://github.com/drupal/drupal/blob/8.0.x/core/modules/system/tests/mo...
Comment #8
cilefen commentedHere is a working example of hook_library_info_build(): http://cgit.drupalcode.org/mathjax/tree/
At least, I hope it works.
Comment #9
hatuhay commentedDeclare CDN libraries on
libraries.ymland did not work, this is the declaration:Is this a bug??
Comment #10
cilefen commentedWhat is the filename of that library file? That declaration will make a library named {whatever module machine name is}/bootstrap-cdn. Is that what you are attaching?
Comment #11
hatuhay commentedThis is how I am calling the library.
$page['#attached']['library'][] = 'bootstrap_library/bootstrap-cdn';Is this what you mean?
It works perfect with local libraries, but not for CDN
Comment #12
cilefen commentedYes, it was what I meant, but that seems fine.
Have you tried with https:// instead of protocol-independent //, just to see?
Comment #13
cilefen commentedRegarding #5, what actually happens? If you disable JS aggregation, is anything JS file included? Are there any browser console 404 errors?
Comment #14
cilefen commentedI just cloned 8.x-1.x and hacked it a little so it loads only from the CDN and it totally works. It's loaded in the HTML.
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>So I don't think the library file is the problem here.
Comment #15
hatuhay commentedJS aggregation is disable to check what is being loaded.
The file is not declared.
Tried also with http: included before, but as I said, file is not declared.
Installed mathjax and it is loading external files, compare codes and look the same.
Comment #16
cilefen commentedYou must attach the library in or altering it will have no effect. This is a diff against 8.x-1.x.
Comment #17
hatuhay commentedYes thanks for the patch, corrected what you mention with no success.
But did you get it to work?
I did not.
Comment #18
cilefen commentedWith that patch in, if I pick a CDN version in the admin interface, the libraries are attached to the page on the CDN. The patch is not intended to really be committed, it is only a test.
Comment #19
droplet commentedCool, working for me now. I think it should also call clean cache explicitly (or use hook_library_info_alter instead), or any other smart way?
Comment #20
hatuhay commentedYes!!!
Finally working.
Need to do a fresh installation, configuration was glued.
Clear cache several times with drush and no success.
Still an issue here I will address later.
Thanks you all guys.