So we wanted to minify our Javascript and CSS files in our symfony 2 app.

Following the symfony's cookbook seemed pretty easy but we just did not know how to install/use node executable on Heroku.

Turns out to be fairly easy : you have to use multiple heroku buildpacks.

  • If you have not done it yet add a default buildpack :

    heroku buildpacks:set heroku/php

  • Then add the nodejs buildpack in order to be able to use uglifyjs2 :

    heroku buildpacks:add -i 1 heroku/nodejs

  • Add a file at the root of your symfony project named package.json with the following content in it :

    { "engines": { "node": "4.2.3" } }

    N.B.: of course replace "4.2.3" with the node version your are using (that you can find with node -v)

  • Finally follow the cookbook and you should be able to minify your files on heroku without any problems.

The command heroku buildpacks should print something like that : Screen Shot 2015-12-18 at 14.58.32

Cheers!

Grégoire Willmann

French entrepreneur

gwillmann lejonqc


Published