Reputation: 6892
Using Symfony2 and LESS, I'm having a hard time to find a nice way to import assets. E.g, if I want to import an asset in my LESS-file located in @bundle/Resources/public/css/file.less
, and the asset is located at: /web/assets/vendor/foo/bar.less
(considering /
as project root).
Using ../../../../../../web/assets/vendor/foo/bar
works, which isn't very pretty. /web/assets/vendor/foo/bar
doesn't work either, since LESS doesn't know where the project is located.
Are there any prettier solutions than above?
Upvotes: 0
Views: 307
Reputation: 6892
I solved this by switching to Less.php, and then specifying a path
in my config.yml
. Full example:
#config.yml
assetic:
filters:
lessphp:
apply_to: "\.less$"
paths:
- "%kernel.root_dir%/../web"
Which made it possible to use e.g:
@import 'assets/vendor/foo/bar';
Upvotes: 0
Reputation: 4430
Not directly a solution, but may be some inspiration:
I am using assetic filter and sass, and below config is works well
assetic:
filters:
scss:
load_paths:
- '%kernel.root_dir%/some/scss_path'
- '%kernel.root_dir%/some-other/scss_path'
and there is --include-path option if you compiling your less manually:
$ lessc styles.less --inlude-path="/web/assets/vendor/foo"
are you using less.js ? in production is recommended to use precompiled css. I think assetic is proper solution, especially if you are using symfony. It can compile your less in runtime when you are in development mode, and then can simply use assetic:dump
to compile all your less for production mode.
Upvotes: 1