2

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.

10
  • That "exceeded the timeout" message hints (to me) that the this is an Assetic specific option. In any case, the max execution time for the CLI should be unlimited. Commented May 27, 2014 at 7:10
  • So, the 60 seconds is defined in Assetic\Util\ProcessBuilder. It has a setter method for the $timeout property but I'm not sure how to set it via the console command. Commented May 27, 2014 at 7:15
  • I tryied to change manually the value of timeout in processbuilder and I edit my question with my results. Commented May 27, 2014 at 7:31
  • CLI and apache have separate php.ini files. Are you sure you edited the correct php.ini? Commented May 27, 2014 at 8:03
  • Though this doesn't specifically answer your question it may be worth noting that the YUI Compressor is going through a deprecation process. (symfony.com/doc/current/cookbook/assetic/yuicompressor.html). It is now recommended to use uglify for minification. (symfony.com/doc/current/cookbook/assetic/uglifyjs.html) Commented May 27, 2014 at 8:03

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.