I have created module specific less file in magento according to guide at below location.


Now I want to be able use magento 2 default ui library inside _module.less file. So how can I add reference to _lib.less file so that I can use all available mixins and variables inside my _module.less?

I know I can do that in _extend.less but how to in case of _module.less Currently php bin/magento setup:static-content:deploy -fgives error when using library.

Thanks in advance.

Solution has been found as I had defined my new variable and mixins in _extend.less and _module.less was not able to use those variables and therefore I was getting errors.

  • what error are you getting? and which reference of library you want to use?
    – Ruhani
    Jun 6, 2018 at 9:17
  • In my _extend.less I defined my new breakpoint @new-breakpoint:959px and therefore _module.less was not able to access _extend.less and I had to redefine this variable to solve the error. Jun 6, 2018 at 9:35
  • please share your path of _extend.less with the variable
    – Ruhani
    Jun 6, 2018 at 10:01
  • my _extend.less is in app/design/frontend/vendor/theme/web/css/source/ folder and _module.less is in app/code.. as mentioned in question Jun 6, 2018 at 11:20

1 Answer 1


I can use magento UI library in _module.less but not my custom new variables (e.g.declared for new breakpoints and so on) in _extend.less.

Now as _module.less is imported though @magento_import directive and therefore all files named _module.less from all modules will be imported but it has no connection with _extend.less file because in hierarchy _extend.less is imported at last.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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