Symfony 2 how to import LESS files from another bundle

assetic, less, symfony

Solution

I think that you must use the paths from web/bundles dir.

i'm importing files this way:

i have 2 less files:

- `src/Acme/FirstBundle/Resources/public/less/style1.less`

- `src/Acme/SecondBundle/Resources/public/less/style2.less`

I want to import style1.less into style2.less

style2.less:

@import "../../acmefirst/less/style1";

using: cssrewrite filer, lessphp

also remember to refer the LESS files using their actual, publicly-accessible path: http://symfony.com/doc/current/cookbook/assetic/asset_management.html#including-css-stylesheets

Problem

LESS has the power to @import other LESS files. This question is intended to find a solution to import LESS files within LESS files from another Bundle in a Symfony project I'm working on a Symfony2 project, using LESS and Assetic to watch changes. My LESS files are able to import other LESS files but only if they are in the same bundle. If I try to import from another bundle Assetic watch stops with error "variable undefined" because the import fails. I've tried all sorts of paths in the import: In a LESS file in another bundle: ``` @import "../../../../MainBundle/Resources/public/less/colors.less"; @import "../../../../../../src/website/MainBundle/Resources/public/less/colors.less"; @import '/bundles/main/less/colors.less' @import url('/bundles/main/less/colors.less'); ``` I'm sure I've tried several correct paths, but they never work because the file is in another bundle and the Assetic watch / LESS compilation processes don't do this well between the bundles. Any ideas anyone?

Original source