Search code examples
cssmodulesassdrupal-7compass-sass

Drupal-add-css not responding


I'm using the following code to include javascript and css:

if( $form['#node']->type == 'e_form' ){
    drupal_add_css( drupal_get_path('module', 'e_form') . '/css/stylesheets/screen.css' );
    drupal_add_js( drupal_get_path('module', 'e_form') . '/js/react.js', 'file' );
}

The javascript code loads but the css does not.

The css is compiled via compass from a SCSS file. Screen.css contains the resulting css code - so it all appears OK.

The module has the following structure:

.
├── css
│   ├── config.rb
│   ├── sass
│   │   ├── ie.scss
│   │   ├── print.scss
│   │   └── screen.scss
│   └── stylesheets
│       ├── ie.css
│       ├── print.css
│       └── screen.css
├── e_form.features.field_instance.inc
├── e_form.features.inc
├── e_form.info
├── e_form.module
├── e_form.strongarm.inc
└── js
    └── react.js

However, the styling does not take effect on the website. Am I missing something?


Solution

  • As it turns out I was not doing anything wrong - not really.

    The issue is the name of the css script - screen.css. My guess is Drupal does not like multiple screen.css files even if they are located in different parts of the project.

    I renamed my script as style.css and adjusted the code accordingly then my styling loaded as expected.