Trying to include assets (js, img, css) in a drupal 8 module

Solutions

I think you should change it to just

{{ attach_library('chess/chess') }}

Rather than the absolute path to a CSS file.

Tags: Html / Css / Drupal

Similar questions

What is the best approach to manipulate assets in Drupal from .Net application?
I'm beginning work on a project that will access a Drupal site to create nodes on the site. This includes file uploading, as the project is to allow people to upload pictures en mass to a Drupal site with minimal ado. Note that my application is written in .Net. What I would like to know is the best approach to achieve the same? Based on initial re...
Referencing Assets in Drupal
I'm helping a colleague configure a new box for an existing Drupal install with multiple sites. It's functioning, but I've noticed that all assets are being referenced as /sites/<site-name>/files/image.png. I don't know from Drupal, but it strikes me that Drupal should be abstracting the logical site from the code so that site-specific assets...
How can I use webform to upload assets and create a project that can be assigned to different users
I am trying to put together a creative request form that a client would fill out. A studio manager would then follow up and assign to a project manager. I am using webform and rules as a starting point with the possibility of using Open Atrium.
Loading of assets via Libraries API
I'm writing a new module which has a dependency on an external library. In Drupal 7 I would use hook_libraries_info giving the name of the library the required assets and Drupal would search the valid locations, libraries directories, to load these assets when required. Drupal 8 introduces *.libraries.yml and after reading https://www.drupal.org/no...
Get path to theme assets in Twig template
I have a question about getting a path to an image in a Twig template. The image is not assigned to a field or something. Just a static image which is stored in "MYTHEME/image/icon/my-icon.png". In Drupal 7 I get the path in my node.template with the following code: How does it work with in Drupal 8? I tried to pass a variable in template_preproces...
How to load jQuery assets before blocks and regions
I need a jQuery script to load immediately before a certain block shows on my Drupal 8 front page. I'm trying to use the following but I get 'TypeError $ is not a function' in code inspector. Here's my script: The problem is the first line. In Drupal 8 what is the preferred way to write this script to accomplish what I want?

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.