Reputation: 327
I am trying to
php app/console assetic:dump
to test my prod environnement. My css file is generating but not my js file. I have this error message :
C:\wamp\www\projet>php app/console assetic:dump --env=prod --no-debug
Dumping all prod assets.
Debug mode is off.
09:48:02 [file+] C:/wamp/www/projet/app/../web/css/666.css
[Assetic\Exception\FilterException]
An error occurred while running:
"C:\Program Files\nodejs\\node.EXE" "C:\wamp\www\projet\app\Resources\node_
modules\.bin\uglifycss" "C:\Users\GoeresAdmin\AppData\Local\Temp\inp3AC2.tm
p"
Error Output:
C:\wamp\www\projet\app\Resources\node_modules\.bin\uglifycss:4
case `uname` in
^^^^
SyntaxError: Unexpected token case
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
This is my javascript block in my layout :
{% block javascripts %}
{# jQuery depuis le CDN de Google, ou fallback sur une copie locale #}
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
{# Tous nos javascripts avec Assetic #}
{% javascripts output='js/666.js' filter='?uglifyjs2'
'js/*.js' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}
And my running css block :
{% block stylesheets %}
{% stylesheets output='css/666.css' filter='?uglifycss'
'css/*.css' %}
<link rel="stylesheet" href="{{asset_url}}" type="text/css" />
{% endstylesheets %}
{% endblock %}
I have this line in my app.php :
$kernel = new AppKernel('prod', false);
My config.yml :
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
filters:
uglifyjs2:
bin: %kernel.root_dir%/Resources/node_modules/.bin/uglifyjs
uglifycss:
bin: %kernel.root_dir%/Resources/node_modules/.bin/uglifycss
EDIT :
I edited my code to use uglify instead of YUI. But it is worse than before because none of JS and CSS are running now in prod.
Upvotes: 2
Views: 1396
Reputation: 2605
You configured the wrong paths for the uglifyjs
and uglifycss
scripts. Assetic executes these scripts via the executable of Node.js - but you configured the paths to the binary versions of uglifyjs
and uglifycss
instead (which are standalone).
The correct configuration would be:
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
filters:
uglifyjs2:
bin: %kernel.root_dir%/Resources/node_modules/uglify-js/bin/uglifyjs
uglifycss:
bin: %kernel.root_dir%/Resources/node_modules/uglifycss/uglifycss
The correct path to the uglifyjs
script depends on your installed version.
Upvotes: 3