Which is then the best way to extend less files content in <module>/web/css/source/module/
, like for instance Magento_Checkout/web/css/source/module/_minicart.less
?
Assuming that to
A) OVERRIDE
- theme related less you must create (or copy) a less with the same name of the parent theme and put it in your theme like this
theme-frontend-blank/web/css/source/_buttons.less
-><your-theme>/web/css/source/_buttons.less
- module specific less you must create (or copy) a less with the same name of the parent theme and put it in your theme like this
theme-frontend-blank/Magento_Theme/web/css/source/_module.less
-><your-theme>Magento_Theme/web/css/source/_module.less
- UI lib less you must create (or copy) a less with the same name content in the library folder and put it in your theme like this
magento2-base/lib/web/css/source/lib/_buttons.less
-><your-theme>Magento_Theme/web/css/source/lib/_buttons.less
and to
B) EXTEND
- theme related less you must create an _extend.less file in your theme adding _extend in the name like this
<your-theme>/web/css/source/_navigation_extend.less
to extendtheme-frontend-blank/web/css/source/_navigation.less
AND register that file with @import directive in the _extend.less of the theme content in web/css/source ->@import "_navigation_extend.less"
- module specific less you must create an _extend.less file in your theme module path like this
<your-theme>Magento_CatalogSearch/web/css/source/_extend.less
which extends the Magento_CatalogSearch original _module.less - UI lib less you must create a less with the same name content in the library folder adding _extend in the name like this
<your-theme>Magento_Theme/web/css/source/lib/_buttons_extend.less
to extendmagento2-base/lib/web/css/source/lib/_buttons.less
AND register that file with @import directive in the _extend.less of the theme content in web/css/source ->@import "lib/_buttons_extend.less"
Theory must suggest you create a _minicart_extend.less but it doesn't automatically work. Maybe you should import that file in the _extend.less of that module like explained in B1 or B3?
And why these components extending less are not automatically included in the parsing of the css if this is the correct way to extend them but must be imported in the _extend.less?
(Here comes also another question: what's the differences between web/css/source/lib/_buttons.less
and web/css/source/_buttons.less
? 😕)
I'm a bit confused. Hope someone could help me.
Sorry for this long text.
Sources: