Here is a complete working example at least on Symfony 2.8. This example using Assetic and is supposed to work with embed file in your css.
Here the arborescence
/app
/src
---/Acme
------/MyBundle
---------/Ressources
------------/public
---------------/css
------/MyOtherBundle
---------/Ressources
------------/public
---------------/css
/web
---/bundles
------/acmemybundle
------/acmemyotherbundle
---/css
------/built
So in let's say /src/Acme/MyBundle/Ressources/public/css/main.scss is the file with all the declaration that I want to import in my other bundle (in my case I use sass but it's the same with less).
In /src/Acme/MyOtherBundle/Ressources/public/css/mycss.scss I'll do :
@import "../../../../MyBundle/Resources/public/css/main";
This refer to the classic physical location of the file, so your IDE will find it.
Now the interesting part. We want to compile, minify, and rename all the scss file into only one css file. We can do this with Assetics.
In a twig file where you load your css (in my case /app/Ressources/views/css.html.twig).
{% stylesheets
filter='compass'
filter='?uglifycss'
filter='cssrewrite'
output='css/built/myMinifiedAndCompiledSass.css'
'bundles/mybundle/css/*.scss'
'bundles/myotherbundle/css/*.scss'
%}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}">
{% endstylesheets %}
==> Here you have to refer the file from the /web directory (so using 'bundles/acmemybundle..' syntax. You need to install the asset in symlink mode. (php app/console asset:install --symlink)
==> You can put whatever you want in output filemane and location since you stay in the web directory.
And finaly in your conf.yml
# Assetic Configuration
assetic:
filters:
cssrewrite: ~
sass: ~
compass:
load_paths:
- "/usr/bin/compass"
- "%kernel.root_dir%/../src/Acme/MyBundle/Resources/public/css/"
uglifycss:
bin: %kernel.root_dir%/../node_modules/.bin/uglifycss
uglifyjs2:
bin: %kernel.root_dir%/../node_modules/.bin/uglifyjs
The important part here is the load_paths in compass.
In the basic set up you have compass : ~
You need to change it for :
compass:
load_paths:
- "/usr/bin/compass"
- "%kernel.root_dir%/../src/Acme/MyBundle/Resources/public/css/"