Showing results for 
Search instead for 
Did you mean: 

No way for a theme or extension to import LESS files from vendor directory

No way for a theme or extension to import LESS files from vendor directory

Feature request from leoquijano, posted on GitHub Apr 18, 2016


As described in #2264, there's currently no way to import LESS files from a theme or extension directory to the vendor/ folder. This is particularly relevant for theme developers since most custom themes could include content from different LESS libraries, and those libraries are better maintained using Composer or Bower (Bower can be configured to also put packages inside vendor/).

So suppose I have this in my theme's main.less file:

@import '../../../../../../../vendor/twbs/bootstrap/less/bootstrap.less';

Now, I could use Bootstrap compiled CSS, but that wouldn't allow me to use variables and mixins from that deployment. If I try to copy Bootstrap files directly in the theme web directory, then the LESS preprocessor will pick them up and fail, since it tries to compile every file in the Bootstrap library instead of just the main one (which imports the other ones).

(And also, it's better to keep external CSS libraries in the vendor directory anyway) The error shown is this:

File path '../../../../../../vendor/twbs/bootstrap/less/bootstrap.less' is forbidden for security reasons.>

I tried to symlink the file (which is not always the best solution since some deployments may fail to reproduce symlinks adequately, especially on Windows), but it's not working either. I'll probably have to copy the full Bootstrap code in a file as a workaround, but it's more maintainable to enable some way of importing from vendor/ directory.

New Member

Comment from tkacheva, posted on GitHub Oct 19, 2016

@leoquijano Currently there is no such feature in Magento to reference web assets of 3rd party library installed via Composer. We have issue opened in the backlog MAGETWO-52044 to add this option.

New Member

Comment from giacmir, posted on GitHub Oct 20, 2016

Actually this is not a "new Magento feature", but a standard less behaviour that Magento has broken by customizing the less pipeline. I tend to consider this a bug, not a feature request.