Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, when can D8 version be expected? I would kill for this right now but I don't have the time to rewrite the code myself :(
Drupal 8 port tracker: https://www.drupal.org/node/2619554
Comment | File | Size | Author |
---|---|---|---|
#56 | less.zip | 53.1 KB | ion.macaria |
#55 | 0001-debugging-css-aggregation.patch | 836 bytes | ion.macaria |
#40 | composer.json-drupal8_version-2224585-D8.patch | 1.1 KB | sjpagan |
#28 | less-settings.png | 57.8 KB | SchnWalter |
#28 | less-add_drupal8_version-2224585-27-D8-do-not-test.patch | 131.37 KB | SchnWalter |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedThis is my quick fix which uses inline css instead of creating new files and it's parsing files on every request. It uses https://github.com/oyejorge/less.php/releases parser in module's "assets/vendor/less.php/Less" directory.
Comment #2
corey.aufang CreditAttribution: corey.aufang commentedSo there is a slight hold up on this.
I had first looked at porting to D8 around a year and a half ago, but at the time decided to postpone since D8 specs seemed to be in rapid flux.
Since then, D8 now requires PHP 5.4 which my Ubuntu 12.04 laptop does not support.
So as soon as I figure a way to get a reasonable development environment going, a D8 port will be started.
I've been looking at a Lenovo w540 and possibly switching back to Windows, which would bring me up to 5.4-5.5.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedTry http://www.dev-metal.com/how-to-install-latest-php-5-4-x-on-ubuntu-12-04... (1st result from google :) )
Comment #4
corey.aufang CreditAttribution: corey.aufang commentedYeah, I can't use that method because there are still some of my clients that are on Drupal 6 and don't want to upgrade.
I've been looking at the phpbrew method to be able to switch to any php version that I need at that moment.
Comment #5
Undrium CreditAttribution: Undrium commentedHeyas, what's the status on this one? Our team is dire to use this module to the 8th. :)
Comment #6
Niels de Ruijter CreditAttribution: Niels de Ruijter commentedBecause #1 didnt seem to work for me, I made this very primitive implementation. No idea if this is the correct way in Drupal 8, so correct me if Im wrong.
Comment #7
Martijn Houtman CreditAttribution: Martijn Houtman commentedI am reading about an effort for Assetic being integrated into D8 core. Maybe a collaboration would be a good idea.
https://www.drupal.org/node/1751602
https://www.drupal.org/node/352951
Comment #8
joelpittet@Martijn Houtman it was removed unfortunately #2356845: Remove the assetic library.
Not enough people got behind flushing out how to meld it with D8. Though there are a bunch of issues getting through now that pave for maybe an easier integration later if someone wants to pick it up again.
#2377397: Themes should use libraries, not individual stylesheets
#2378095: Convert all remaining attached individual CSS/JS assets to attached asset libraries
#2382557: Change JS settings into a separate asset type
Comment #9
corey.aufang CreditAttribution: corey.aufang commentedOk, so I had been holding off on a D8 version because D8 was still in Alpha, or so I had convinced myself.
Part of my original hesitation was lack of experience with OOP for PHP, something that I have recently become much more familiar with.
Some of this is now reflected in the latest less 7.x-4.x-dev.
I would like to carry over some of what I've done in 7.x-4.x to 8.x-4.x, but especially finish and release 7.x-4.0 before I get too in-depth with 8.x-4.x.
So if any of you have some time, please review 7.x-4.x and let me know what you think.
If there are any WTFs, code or otherwise, or anything that you feel could be done better, please let me know.
Comment #10
corey.aufang CreditAttribution: corey.aufang commentedComment #11
Undrium CreditAttribution: Undrium commentedJust want to mention that as of beta version 4, the ability to inject "inline" css and JS is removed. The two temporary solutions mentioned in this thread are therefor obsolete, however the latter can be modified to work if you just remove the type declaration of "inline".
Comment #12
corey.aufang CreditAttribution: corey.aufang commentedUnless any major issues crop up in the 7.x-4.x branch in the next few days, 7.x-4.0 will be releasing soon.
Work on a D8 version will begin immediately after.
Comment #13
corey.aufang CreditAttribution: corey.aufang commentedWork has started on the D8 version.
I'm not going to list the dev release on the project page until I have it minimally working.
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commentedHi. I have updated my ongoing project to the latest D8 alpha and then HEAD and as #11 mentioned the support for inline styles was dropped so I had to update my solution from #1 to this:
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedMy current version:
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdated
Comment #17
veleno CreditAttribution: veleno commentedHello ivanjaros, I'd like to implement your code in my custom theme, into the THEMENAME.theme file but I've not been able to make it work.
Could you please help me modifing your code so it will work if used into the theme?
Thank you for your time.
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commentedhttps://gist.github.com/ivanjaros/2e53f8af114c4fd44f96
Comment #19
sachbearbeiter CreditAttribution: sachbearbeiter commentedComment #20
veleno CreditAttribution: veleno commentedThank you ivanjaros, but I've not been able to convert your shared code in a module or a template function.
I'm new to drupal 8 and to module creation.
Would you please be more clear?
Thank you
Comment #21
Anonymous (not verified) CreditAttribution: Anonymous commentedcopy the code from .module, .info.yml and composer.json into a directory, run composer install. Gist has split the module into files where their name is the directory structure so it looks weird even if you download it.
Comment #22
veleno CreditAttribution: veleno commentedThanks again ivanjaros, I've been able to make it work.
I've uploaded the working version of the module in this post, I've put the less.php library inside the module directory.
It compiles Bootstrap 3 correctly now, I'm using it with the less sub-theme starterkit of the Bootstrap theme at https://www.drupal.org/project/bootstrap.
Hope the full Less CSS Preprocessor module could be released as soon as possible for Drupal 8
Regards
Comment #23
Frantsuzzz CreditAttribution: Frantsuzzz as a volunteer commentedHello veleno. Added Developer Mode to the module store_less_css.
It may be useful.
Regards
Comment #24
SchnWalter CreditAttribution: SchnWalter commentedHello all,
I have just cloned the module repository to https://gitlab.com/SchnWalter/drupal8-less and I will start working on having a basic module for Drupal 8 sometimes in the next weeks.
Regards,
Walter S.
Comment #25
SchnWalter CreditAttribution: SchnWalter commentedQuick question: "LESS engine" isn't really a proper term. Would it be OK if I replace the terminology to use "preprocessor" which is a more popular term? I know it will break the translations but it would be less confusing. I've never seen "engine" used to describe these kind of libraries.
Comment #26
SchnWalter CreditAttribution: SchnWalter commentedI've converted the "engines" to a LessEngine annotation plugin and I've added a settings form page that extends ConfigFormBase and right now I have a working module on my local machine, that is not committed onto the gitlab repo, I'll need to do some cleanup and refactoring before I push a simple working version onto that repo.
I've been working on supporting the devel and watch modes and I've finally found a solution by using an approach similar to how the image styles work. Basically we don't save the files on disk when devel mode is enabled, but we stream them directly to the browser. I've chosen this approach because I could not find a clean way of implementing the functionality without introducing some changes into Drupal core, and I think that this approach is perfectly suitable since Drupal developers are already familiar to this pattern.
And I think that we should not add
hook_less_variables_SYSTEM_NAME_alter
andhook_less_paths_SYSTEM_NAME_alter
in the D8 version since the values for those hooks are not namespaced and there is no to only alter variables declared by a single module and those are very edge cases. We should simplify things. Maybe we can add those back later after a fist beta version has been released.Comment #27
SchnWalter CreditAttribution: SchnWalter as a volunteer and commentedI've pushed a working Drupal 8 port onto: https://gitlab.com/SchnWalter/drupal8-less
There are some missing features or issues:
* Watch mode is not finished yet. We'll need to update the
less_css_cache_files
state to include more information.* In 7.x-4.x a module/theme can define default variables and import directories inside .info files that are only available to the less files from that module/theme. I'm not sure if you agree, but I believe that feature ads a bit of confusion and I don't see any relevant use cases.
* There are not LESS settings on the theme settings page.
* WYSIWYG .less files are not compiled.
* Autoprefixer has not been enabled, code is commented out. It only works with files and the current devel mode does not create files.
* Tests are missing, and the old tests have not been updated.
* Demo module has not been updated.
* README.md file has not been updated.
Comment #28
SchnWalter CreditAttribution: SchnWalter as a volunteer and commentedAdded patch and admin settings page screenshot.
Comment #29
corey.aufang CreditAttribution: corey.aufang commentedThis is not based on a review of your code.
I just went over your notes and provided feedback to give an idea of the road ahead.
The module supplants the preprocessor and then delegates the task to the selected library.
I was doing a bunch of "Libraries" hooks and integration and didn't want to have too much confusing terminology in the code, but for the radios label it should probably be "Less library:".
There was a lot of backwards comatibility code in the libraries hooks to work with all the paths that the module support for legacy reasons.
With the lower chance of users doing the D7->D8 migration, dropping support to older libraries path locations should be pursued.
Streaming the files seems like it will introduce significant lag time to page loads during when devel mode is enabled, even with cache headers for the browser.
Image styles work fine because you change their configuration for more infrequently than when adjusting CSS styles during theming.
D7 devel mode checked for changes in a file and its dependencies before recompliling, and all results were stored to disk to be loaded directly through the web server bypassing PHP.
Could you tell me the specific issues you had adapting the Devel Mode for D8?
#2730749: Long-polling watch mode introduced the concept of long-polling instead of the rapid polling that I had implemented.
In short, you make a AJAX request to a PHP script that checks for changes, but keeps the connection open until changes are detected, or if execution time is about to be reached. The JS will reload the CSS if the PHP returns data, or restarts the AJAX if the connection is closed without result.
This is also know as Comet.
Either we figure out how to make them function as D7 does, or we drop them.
Import directories, I think it was so that you could specify a "library" .less file that might not be located in the same module, but possibly a sibling module. Don't really remember specifically.
If I was doing it again, I would not use the .info file and only use hooks for providing these, so probably don't need to support in D8.
You can make changes to things like key color variables and those variables will then be used by the .less files when they are re-compiled, all directly from the theme settings page.
No FTP or other access required.
Autoprefixer removes the need in most cases for Less libraries that handle things like box-shadow for all the different browsers.
The original reason for making this module 6+ years ago is that it was difficult to get the original Less compiler setup and running on a development machine and to have it integrated into your workflow without issues.
This is drastically easier now.
Additionally, since the .less file developed by one person using a specific version of the compiler, will be run by another person with a potentially different version and/or compiler, there is a chance that the file will not compile due to changes in supported language features.
So with the above I believe that the focus of the module needs to be narrowed.
I believe that its a bad idea to promote the module compiling any .less file that you have not made. Specifically, if you are developing a website and making a custom module/theme for the site, you can use the Less module to compile your .less files to CSS.
But, you should not use this module to compile .less files from contributed modules/themes/libraries, not should you as a module/theme developer intend for users to use this module to compile .less files that you provide in your module.
There are just too many issues that can arrise from what people assume the language supports, when the library is lagging behind feature wise, or the installed version of less.js is outdated.
The only thing that I see making this module more valuable than compiling in your local/dev copy is the theme settings form, because you can make changes to the styling without having to know much about CSS. It also means you can mess things up easily, but thats the case with most things.
Properly functioning sourcemaps also factors into this. They need to be working 100% as it is unreasonable today to not support them, since all major browsers to. There have been issues implementing it correctly since the derived output .css files do not live in the same directory as the source .less files, the pathing gets messed up.
Main items:
Everything is flexible. All feedback in welcome. Nothing is set in stone.
Comment #30
SchnWalter CreditAttribution: SchnWalter as a volunteer and commentedThanks for your feedback. I'll go over every point and provide an answer later this week.
About Devel Mode: There are some cache issues that I could not find a way to get around them and I wanted to quickly have a basic working module and this was the quickest and simplest workaround I could find. But yes, maybe we can also cache the file and just serve it via Drupal if we don't find a solution for the cache issue inside
\Drupal\Core\Asset\AssetResolver::getCssAssets()
. Maybe we could introduce an extra hook in D8 core to alter libraries. (Not this hook: https://www.drupal.org/node/2785815)Comment #31
SchnWalter CreditAttribution: SchnWalter as a volunteer and commentedComment #32
rphair CreditAttribution: rphair at COSD commentedthanks @SchnWalter - I've installed the Gitlab version on Drupal 8.2.1, with Libraries module already installed & just
oyejorge/less.php
extracted into/sites/all/libraries/less.php/Less.php
. I get the following message when visiting configuration page/admin/config/development/less
:Fatal error: Class 'lessc' not found in /.../modules/less/src/Plugin/LessEngine/LeafoLessphp.php on line 64
Have I left something out? If so please let me know & I will happily continue to test.
Comment #33
SchnWalter CreditAttribution: SchnWalter as a volunteer and commentedI just updated the module and added the extra check required to prevent that issue.
Comment #34
rphair CreditAttribution: rphair at COSD commenteddear @SchnWalter - thanks so much, now the module installs and I have it working with
less/less.js
- it's really nice to have this up & running in any form on Drupal 8.I still can't make it work with
oyejorge/less.php
- the option is still greyed out after making sure Less.php is there at/sites/all/libraries/less/Less.php
. However you installed this code to get the screenshot above with that option selectable, I would love to know.I've tried clearing the cache, also tried putting the library in
/libraries
. I do have the Libraries module installed properly & I haven't downloaded the source code version by mistake.Comment #35
rphair CreditAttribution: rphair at COSD commentedp.s., the gitlab instructions also say to install the file at
/sites/all/libraries/less.php/Less.php
but I am not seeing it recognised there either.Comment #36
SchnWalter CreditAttribution: SchnWalter as a volunteer and commented@rphair, I didn't update any documentation.
I'm using this composer command to install the
oyejorge/less.php
library.composer require oyejorge/less.php ~1.7
Though, I'm not sure how one would deal with installing custom PHP libraries and exposing them to the Drupal autoloader without using Composer.
If you want to give composer a try, you should check this page: https://www.drupal.org/docs/develop/using-composer/using-composer-to-man...
Comment #37
rphair CreditAttribution: rphair at COSD commentedyes, it's recognised after installing with composer (
composer require oyejorge/less.php
was enough for me). Thanks very much, I agree this way is better, though other libraries I have worked with so far (e.g., D8 dependencies of responsive_menu) will also be recognised by the Libraries module when they are installed manually. Very nice to have this working with both less.php and less.js now...Comment #38
sjpagan CreditAttribution: sjpagan commentedhi guys,
i read all list of comments, i decide help you to porting this module to D8,
I have a great need for this module, for anything do not hesitate to contact me.
My Starting repo is: https://gitlab.com/SchnWalter/drupal8-less
Comment #39
sjpagan CreditAttribution: sjpagan commentedPlease see this documentation : https://www.drupal.org/docs/8/understanding-drupal/directory-structure, using composer in less folder place "oyejorge/less.php" on vendor folder, this folder used only for core of drupal 8.
The correct folder for this package is libraries, the composer.json is not correct :-(
Comment #40
sjpagan CreditAttribution: sjpagan commentedHi @SchnWalter,
apply this patch to your repo, it resolve problem to location of libraries less.php in library folder and not in vendor folder, this modify create a folder named
lessphp in libraries folder, but the new name not recognized from module.
Comment #41
sjpagan CreditAttribution: sjpagan commentedComment #42
ion.macaria CreditAttribution: ion.macaria as a volunteer commentedHello, I started to port this module into drupal 8 version with https://www.drupal.org/project/libraries.
All was ok, but when I tried to use function less_element_info_alter(&$type) it reminded me about new style (.libraries.yml) implementation. I don't know how we can alter our style.less element and put a pre_render function on it. Some ideas?
Drupal 7 function:
PS: Sorry for my english.
Comment #43
ion.macaria CreditAttribution: ion.macaria as a volunteer commentedI'm glad to announce about first "Less CSS Preprocessor" module - drupal 8 version.
This works with Libraries API and you can include all less libraries like in drupal 7 version. Also it works with autoprefixer (v5.0 was tested).
This module will detect yml library with "less" name.
Example:
theme_name.libraries.yml
and you can include it on needed pages:
Example(global use):
theme_name.info.yml
Module URL: https://www.drupal.org/node/2619554
Comment #44
ion.macaria CreditAttribution: ion.macaria as a volunteer commentedComment #45
frobCan we get this code back onto drupal.org? It is a huge problem when efforts are split or duplicated in several disconnected repos.
@ion.macaria, this issue is marked needs review. The best way to help is to review the code that is already in place.
@corey.aufang, can this code be brought back into drupal.org so that confusion stops on which version to use? I want to review this, but I have no idea what I am supposed to review at this point.
Comment #46
frobComment #47
frobThis review is from https://gitlab.com/SchnWalter/drupal8-less 7825689a21466c564f6fa084af39e194c2f97ee7
The module seems to work. I would say it is defiantly ready for a dev release. I have two issues,
Comment #48
SchnWalter CreditAttribution: SchnWalter as a volunteer and commentedWe've been using a version of the module in production on a couple of sites for about 8 month now, and I've made some improvements to help with development. I'll push some updates to the github repo next week, or I'll submit a patch if a 'dev' release is made on D.o
Comment #49
ion.macaria CreditAttribution: ion.macaria as a volunteer and commented@frob I have no time, but this month i will try to create a README file, and review code for first stable version.
Comment #50
frob@ion.macaria please combine forces with @SchnWalter. https://gitlab.com/SchnWalter/drupal8-less is farther along and should be brought to d.o
Comment #51
ion.macaria CreditAttribution: ion.macaria as a volunteer and commentedI started to test https://gitlab.com/SchnWalter/drupal8-less module, but after installation i got this error.
Uncaught PHP Exception Drupal\\Component\\Plugin\\Exception\\PluginNotFoundException: "The "" plugin does not exist." at ...\\core\\lib\\Drupal\\Component\\Plugin\\Discovery\\DiscoveryTrait.php line 52
Someone know what's the problem?
Update:
This happens where I try to access admin/config page and none library is activated.
Comment #52
frob@ion.macaria that sounds like a legitimate bug. I think I may have run into it to but figured it was another a problem with something else I was working on.
Did you try requiring the less lib with composer? If I remember right I ran a cache rebuild and that cleared it up. There might be a bug with the code that causes an error when there are no libraries installed/detected.
Comment #53
ion.macaria CreditAttribution: ion.macaria as a volunteer and commentedModule https://gitlab.com/SchnWalter/drupal8-less works ok.
@frob I can't found issue 2 (I still have to rebuild the cache everytime I make a change),
but I saw module is not working where CSS is aggregated.
Anyway, this module saved me a long time in D7, because I did not have to reload the page. I want to say, we have to implement watch mode! Otherwise this module is useless, because alternative can be gulp on node.js.
This week I will start to avoid CSS aggregation, after that - implementing watch mode.
Comment #54
frob@ion.macaria Read comments 26-29 regarding watch mode. maybe put your efforts into making watch mode work rather than reimplementing the entire module.
All I am saying is that we should be working together. It would be easier if we had an actual patch for d8 to bring it back into drupal.org
Comment #55
ion.macaria CreditAttribution: ion.macaria as a volunteer and commentedThe problem in CSS aggregation was devel mode. I omit it if CSS aggregation is turned on.
Here is a patch.
Comment #56
ion.macaria CreditAttribution: ion.macaria as a volunteer and commentedFirst version with less watch, I know this is not the best code, but can be the beginning.
It's a lot of changes and I think patching is not the best approach.
So, I will put the code here.
Comment #57
RgnYLDZ CreditAttribution: RgnYLDZ commentedI added module in #56 but I get an error like this ;
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of /home/xxxxxx/public_html/xxxxxx.com/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
I get this error when I try to access the Reports page.
I installed lessphp library into the libaries folder in root.
Comment #58
nick_obukhov CreditAttribution: nick_obukhov as a volunteer and commentedThe module from #56 does not compile less wih LESS developer mode = ON (tried with Bootstrap theme /without CDN provider/).
Comment #59
MurzI have found https://www.drupal.org/project/ipless project - can it be used as alternative of LESS module for Drupal 8, or it implement another functional?
Comment #60
sjpagan CreditAttribution: sjpagan commentedI have create new module with less & scss compiler in same module, plese see it to https://www.drupal.org/project/style_management
Comment #61
Pawlus CreditAttribution: Pawlus commented@sjpagan It requires composer, so it's unusable on shared hosts. Should make use of libraries instead. Then again, from what I've seen you just barely can operate Drupal without composer, so I guess there's no helping it.
Comment #62
frob@Pawlus, just because a module requires composer doesn't make it not work on shared hosts. Install with composer locally and then upload the vendors directory to your shared host. Every site should use composer to manage dependencies.
Comment #63
Pawlus CreditAttribution: Pawlus commented@frob In your scenario it's almost certain to run into invalid or forbidden path in autoload.php file, because shared hosts usually overwrite root path. And to fix that you need to run composer, which is either inaccessible or called from ambiguous location, often with php version different than in your installation location. Many shared hosts don't even provide shell access. Not to mention EOL for Drupal 8 is upon us and Drupal 9 has such high requirements basically no shared host can fulfill them.
But there's no point of arguing here about that. Back on topic at hand, I'm using module called Style management mentioned in #60. It's not perfect by any means, but it gets the job done, it could use source mapping. Also it uses less.php instead of lessphp, which is outdated.