Lajdák Marek Lajdák Marek - 4 years ago 306
Twig Question

Symfony assetic - is possible in dev load original files?

I have project on Symfony 3 with installed assetic. I am using it for merging all css together and minify.

Usage in twig template:

{% stylesheets filter='cssrewrite' filter='uglifycss'
'assets/font-awesome-4.6.3/css/font-awesome.css'
...
%}
<link rel="stylesheet" href="{{ asset_url }}">
{% endstylesheets %}


Config:

filters:
cssrewrite: ~
uglifyjs2:
bin: "%kernel.root_dir%/Resources/node_modules/uglify-js/bin/uglifyjs"
uglifycss:
bin: "%kernel.root_dir%/Resources/node_modules/uglifycss/uglifycss"


In prod mode all works as expected. Assetic loads css files from path
/assets/someDir/some.css
and generated minified file (css or js) is in default assetic path
/css/allCss.css
or
/js/allJs.css
.

But in develop mode assetic generate new files from
/assets/someDir/some.css
to
/css/some.css
(each file and not minified) and load css files from there.

QUESTION:

How i can load original files from
/assets/someDir/some.css
in dev mode?

Because in this situation i must after each change in any css or js run
php bin/console assetic:dump --env=dev
and it is unacceptable.

Answer Source

Since you don't want to run php bin/console assetic:dump each time you change a CSS or a JS file, use php bin/console assetic:watch instead, it will automatically regenerate the files on every change of CSS or JS.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download