Magento 2 restricts the Less @import
statement: it can not refer into the reverse path direction:
https://github.com/magento/magento2/blob/4499554d4e47135cdb8f5464e1d7eed3ebfb985e/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/Resolver/Simple.php#L79
So an extension can not use the code like @import '../../_common.less';
So how an extension can import common Less files from both the frontend
and the adminhtml
areas?
The solution is to place the common files into the base
area.
For example, the common file path could be Df/Core/view/base/web/_common.less
And then the common file can be refered from both the frontend
and the adminhtml
areas:
Df/Core/view/adminhtml/web/main.less
:
@import '_common.less';
Df/Core/view/frontend/web/main.less
:
@import '_common.less';