I would like to include a CSS file into my custom module in Drupal 8. I already have another module with only one routing path and one controller function and my CSS works fine there, but not so in the new module. Do I miss something, or is there anything different with multiple routing paths?
module.routing.yml:
module.support_bugs:
path: '/support/bugs'
defaults:
_controller: '\Drupal\module\Controller\moduleController::bugsShow'
_title: ''
requirements:
_permission: 'support_bugs'
module.support_requests:
path: '/support/requests/{param1}'
defaults:
_controller: '\Drupal\module\Controller\moduleController::requestsShow'
_title: ''
param1: null
requirements:
_permission: 'support_requests'
module.support_docs:
path: '/support/docs'
defaults:
_controller: '\Drupal\module\Controller\moduleController::docsShow'
_title: ''
requirements:
_permission: 'support_docs'
I want to include the CSS for the output of support_changes.
module.library.yml:
module.support_requests:
css:
theme:
src/css/modulestyle.css: {}
And in the end, I include it in my controller.
moduleController.php:
namespace Drupal\module\Controller;
class moduleController {
//other functions
public static function requestsShow($filter=null){
//some code inhere
$build['content'] = array(
'#markup' => $output);
$build['#attached']['library'][] = 'module/module.support_requests';
return $build;
}
//other functions
}