cancel
Showing results for 
Search instead for 
Did you mean: 

Custom modules web/css/source/_modules.less not compiled with sass-blank theme

Custom modules web/css/source/_modules.less not compiled with sass-blank theme

Hi @Bartek Igielski

 

First off, seems like you've been putting in a huge amount of work to undertake this project, so thanks for all the hard work.

 

We're looking at using the theme for our upcoming M2 builds, however I've come across an issue that could be a potential blocker for us.

 

In the Magento LESS blank and luma themes per module less files are included in their main 2 stylesheets (styles-l and styles-m) based on the convention of files being place in the following format:

 

<Vendor_ModuleName>/web/css/source/_modules.less

 

Obviously in your SASS blank theme you've changed this to:

 

<Vendor_ModuleName>/styles/_module.scss

 

and you are manually including each .scss file in your theme's styles/styles.scss file.

 

The LESS themes on the other hand make use of the @magento_import variable to automatically find the files of any module included and this even fallback to custom modules where web/css/source/_modules.less files sit within the modules view/frontend directory. (the same also applies for _widget.less files too)

 

Unfortunately the SASS theme does not seem to be able to perform this fallback procedure and means and 3rd party / custom module installed using the web/css/source/_modules.less method of including LESS files are never included in the theme when compiled / deployed.

 

Have you come across this or have any advice on how we might get these LESS files compiled and included when using the SASS theme (or a child of it)?

 

It's also worth further nothing that if a custom module uses the approach discussed as in Alan Storm's LESS guide: http://alanstorm.com/magento_2_less_css where LESS files are auto compiled by Magento by specifically adding the file to the head block one of a layout xml within the module.

 

Many thanks

 

John

3 REPLIES

Re: Custom modules web/css/source/_modules.less not compiled with sass-blank theme

There is no way to compile LESS partials as fallback to SASS styles, b/c it require to compile everything, not single file (and it's slow). Only way to use fallback mechanism is to have SASS styles on every inheritance level (yes, even 3rd party modules have to be rewritten to SASS -> nice tool to simplify this process)

 

Support for compiling styles outside theme dir (like in Alan's example, inside module), will be added in future version of frontools.

Re: Custom modules web/css/source/_modules.less not compiled with sass-blank theme

What is the plan with regards migrating people from using less to sass? Are you talking to extension developers?

 

3rd-party extension support is going to play a big part in that. In my situation, starting a couple of new M2 projects for clients, I would like to use SASS to future-proof the project, but as we tend to use a fair few 3rd-party extensions in any project we would have to wait until they migrated to SASS. Once enough have SASS support we could probably handle the odd 3rd-party extension that we have to maintain our own SASS for.

Re: Custom modules web/css/source/_modules.less not compiled with sass-blank theme

Yep, we have extensions developers on board and Magento guys are caring about supporting every type of users.

We are still working on it, keep calm, as soon as we figure out a way how to fit everyone needs, it will be published.