1

I want to load a custom css file for the admin panel from a custom module folder.

My layout xml file looks like this

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="Vendor_Module::test.css" />
    </head> 
</page>

I've also tried

<head>
    <css src="Vendor_Module::css/test.css" />
</head> 

I tried putting the file in

Vendor/Module/view/web/css/test.css

or

Vendor/Module/view/adminhtml/web/css/test.css

After each I cleared the cache, the page cache and the pub/static folder.

The css file is not loading. Does anyone know why ?

  • 1
    Assuming that your module is enabled, try running bin/magento setup:upgrade – Renon Stewart Feb 23 '16 at 12:49
  • that worked... so php bin/magento setup:static-content:deploy is not enough.... do I have to run setup:upgrade every time i add new js or css file to a module ? – Lachezar Raychev Feb 23 '16 at 13:08
  • I'm not sure, but bin/magento setup:upgrade always seem to solve my issue – Renon Stewart Feb 23 '16 at 13:12
  • ok, 10x. one more question. When I write in a js file from a certain module, I always have to clear pub/static and regenerate full static content so I can check what I've done, how can I escape that on development mode ? – Lachezar Raychev Feb 23 '16 at 13:14
  • According to devdocs.magento.com/guides/v2.0/config-guide/bootstrap/… development mode should not cache those files – Renon Stewart Feb 23 '16 at 13:17
2

Assuming that your module is enabled and configured correctly

Run

bin/magento setup:upgrade

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.