5

I need to use some UI components in a custom module, so I included Magento2 Ui base library in my less file in this way:

@base-dir: "../../";
@import '@{base-dir}css/source/lib/_lib';

This works fine as long as my site is in developer mode. But when I push it to an instance in production mode and launch bin/magento setup:static-content:deploy it fails with this error:

File ../../css/source/lib/_lib.less not found. in reseller.less

There are a couple of bug reports that could to be related to this. Does anyone found a solution?

Edit:

As a workaround I manage to have it working by adding a symlink in my css folder to the lib folder and importing from there, so there are no more relative paths. But it is a very dirty way to accomplish what I need. I would like to see some better and cleaner solutions.

0

In module you can call directly mixins from magento, You don't need import any files. Usually mixins of magento located in folder lib/web/css/source/lib
The only thing you can't is call variables and mixins defined in theme (call mixin from module). Instead you need define your variables/mixins inside _module.less (in your module) and use it later

path _module.less usually

app/code/YourBrand/YourModuleName/view/area/web/css/source/_module.less

area can frontend adminhtml or base.
Because you don't mention any area related adminhtml or frontend so i will assume frontend as default

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.