I'm developing a WordPress theme, and using LESS for the CSS. LESS has many dynamic solution, and I found them helpful throughout my project. I'm using LESS, but not directly, I'm compiling the LESS file into CSS and enqueueing them (.css) into the site <head>. To compile the LESS files, I'm using WinLESS (v. 1.8.1), and it's an excellent and quick one. It has a built-in minfication technique so that with a single click I can (1) Compile the LESS file, and (2) Minify them at once. To ensure site speed I'd like to prefer the minified version of the CSS. But...
But, we all know that a WordPress theme CSS file contains the theme information at the header, like:
/*
Theme Name: my theme
Theme URI: http://www.example.com/
Description: my theme description
Author: you
Author URI: http://www.example-author.com/
Version: 1.0
*/
If I command WinLESS to compile my style.less to Compile && Minify then I get a minified version to style.css, but you know a minified CSS doesn't contain any CSS comments, so the theme information simply blown by the process. And in wp-admin/themes.php page the theme become header-less (unnamed).
I then tried something different. I made my stylesheet into two files:
style.less- contains only the header information a theme needs, nothing elsemy-site.less- contains all the site CSS
I am compiling the style.css as non-minified, but the my-site.css as minified. In style.less I am including or taking all the CSS from the my-site.css with:
@import (less) 'css/my-site.css`;
So that, the minified my-site.css is completely imported to the style.css file (there would be no @import CSS parameter there). They will be included like the regular CSS codes, line-by-line, with the (less) included [details].
PROBLEMS...
That's actually the problem. Though I'm importing a minified CSS file, but the LESS @import (less) is taking the declarations as line-by-line.
Where my my-site.css is like:
*{margin:0;padding:0}html{margin:0;padding:0}
when I'm opening the style.css file it's like:
* {
margin: 0;
padding: 0;
}
html {
margin: 0;
padding: 0;
}
The importing is vanishing the minification completely.
Is there any other solution to @import CSS codes into a stylesheet being minified?
P.S.: I'm completely aware about the WP-Minify plugin (a nice one), and I don't actually want to use it on the first hand.
/*!rather than just/*. (That's recognised by the yui minifier as a comment you specifically want to keep...) I'm hoping that'll keep the comment, but still allow WordPress to recognise it./*!is also recognised by LESS built-in minifier, so most likely it will do the trick.