Difference between _module.less and _extend.less
The answer is somewhat hidden in the Magento docs:
Extending a theme using _extend.less is the simplest option when you are happy with everything the parent theme has, but want to add more styles.
Read more here
Use _module.less when you want to make major changes in styles for a module and use _extend.less for minor adjustments. You'll find more examples on how to override component styles in the link above.
Simple explanation or difference between both:
_extend.less
is the way to extend/modify parent themes styles for example you're happy with your parent theme Luma and just want to change the button styles in your custom theme, all you need to do is create a new file _buttons_extend.less
under web/css/source
in your custom theme and adjust styles in there. Register this file by adding it to the _extend.less
file inside your theme directory.
What if you want to extend styles of a module e.g. checkout module, well you can create an _extend.less
file inside your themes module folder e.g. Magento_Checkout/web/css/source/_extend.less
and add/extend module styling in there.
Now if I added _module.less
file inside my module directory Magento_Checkout/web/css/source/_module.less
I'm intending to override my parent themes styling for this module in which case I need to copy '_module.less
' file from my parent theme's module directory and make modification to that file in which case this file will replace parent themes _module.less
file altogether.
The _extends.less
with an S at the end within the Blank Theme, is a file where they created all the classes that can be extended via LESS
later within the theme, without the need of creating new components or modular structure for style changes. -> For those who don't believe me: https://github.com/magento/magento2/blob/2.3-develop/app/design/frontend/Magento/blank/web/css/source/_extends.less check the file.
The _extend.less
without the S at the end, is for when you are 99% happy with what the parent theme has and you just need to change a couple of things, change some styling and that's it.
About the latter one, my personal opinion, don't use it for your own developing. It creates a big mess later. Keep your structure modular with _module.less
for every module you want to customize and you will get a better outcome & maintainable project at the end.