I'm using assetic for compiling .less
files, and managing assest in general. In dev environment I'm using less compiling via controller.
To keep my repository clean I've set write_to
option in assetic configuration to some directory and set it as ignored by git. In dev it works as expected.
In prod env there is a problem though. Assets are dumping correctly but to the directory set in write_to
option. But links to the assets links to the main /web
directory and breaks.
And here is my question: how to use assetic for assets management to make it working in prod and keep it clean in repository.
Of course I can not commit dev generated assets to git, but it must break at some time.
Here is my assetic config:
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
write_to: "%kernel.root_dir%/../web/assets/assetic"
filters:
cssrewrite: ~
less:
node: '%node_path%'
node_paths: ['%node_modules_path%']
apply_to: '\.less$'
Ok, that was easy :)
I forgot that there is config.yml
and config_dev.yml
, so you can configure anything properly for dev, prod, test and whatever environment.
So it was enough to move line
write_to: "%kernel.root_dir%/../web/assets/assetic"
from config.yml
to config_dev.yml
.
Now in dev env assets are generated to ignored by git dir, and in prod it is generated in /web/
dir and linked properly.