You are not logged in.
It appears that the .min.css file is never regenerated during normal runtime use.
I created a plugin and added a CSS file.
In SuperAdmin debug mode, the CSS file loads with all other CSS files.
When logged in with another user (and at the anonymous login screen), the existing .min.css file loads, but it doesn't contain the CSS from my plugin CSS file.
Is there a manual process to trigger CSS minification?
Offline
When in debug mode, the minified CSS is never used.
Are you manually creating the minification?
How are you loading the CSS with your plugin?
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
$PLUGIN_HOOKS[Hooks::ADD_CSS]['myplugin'] = 'myfile.css';
No, I'm not manually creating the minification. Should I be? That's why I posted the original question!
I presume for compatibility with plugins that bring their own CSS, GLPI would nee to automatically bundle CSS files and minify them.
Offline
GLPI doesn't minify anything during use. The only thing that minifies CSS is the CLI command "bin/console build:compile_scss" and the release build script. This only affects GLPI's own CSS. If a plugin developer wants to serve minified CSS, they need to generate that minified CSS themselves and make sure they refer to the minified CSS file path.
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Hmm I guess that explains why my plugin CSS code isn't packaged on the Login page.
I wrote CSS code to modify the Login page. It works fine if I stick the code in one of the stock x.min.css files.
For the sake of clean architecture, I moved the CSS into a plugin .css file and used the plugin hook to add it. Unfortunately the plugin .css URL is only linked in the HTML page header while logged in (doesn't load on anonymous/login page).
Is there a way to get either the plugin or the css file to load for anonymous page views?
Offline
Maybe by using the "display_login" hook to add a new <link> HTML element.
In the setup.php init function:
$PLUGIN_HOOKS['display_login']['myplugin'] = 'myplugin_display_login';
In the hooks.php file:
public function myplugin_display_login () {
$plugin_path = Plugin::getWebDir('myplugin') . '/myfile.css';
echo "<link rel='stylesheet' href='" . $plugin_path . "'>";
}
Obviously, replace "myplugin" with the internal name of your plugin.
No other plugin hooks are called on the login page currently.
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Ok that makes sense. I actually forgot that you can put a LINK tag for a stylesheet directly in HTML body.
I used the display_login hook and it worked!!
Man its really nice when you get reminded of how simple HTML actually is. We devs often get stuck in overengineered mindsets thanks to dealing with frameworks all the time -- too far removed from the metal. I have to know so many different frameworks, sometimes I think my head is going to blow up.
Thank you!
Offline