Reputation: 524
The Play Framework version 2.1.0 docs state:
by default a rhino based optimizer is used, the native, node version can be configured for performance via requireNativePath setting
but there's no example of how/where to actually do this. When I deploy my app to Heroku the optimization step is taking upwards of 10 minutes and causes the build to fail fairly regularly. Can anyone point me to how I should be setting this requireNativePath flag?
Upvotes: 0
Views: 616
Reputation: 90
There is no easy way to get requireNativePath
to work on Heroku as you will have to fork and modify the scala buildpack to get improvements. though, by following the steps below you will speed up optimization by more than 10X (It was taking me ~700+ seconds to deploy, now it only takes ~65 seconds)
Go ahead and fork the scala buildpack and apply the modifications from here. These modifications essentially install node and npm, then install requireJS node_module.
After you add the modifications to your buildpack, you have to tell heroku to use your custom buildpack via the CLI
$ heroku config:set BUILDPACK_URL=https://github.com/<your user>/heroku-buildpack-scala
Next, modify your Build.scala
project settings by adding this line
requireNativePath := scala.util.Properties.envOrNone("REQUIREJS_PATH")
Next set a config variable on heroku for the REQUIREJS_PATH
via CLI. This is the path that the buildpack modifications will install the r.js file:
$ heroku config:set REQUIREJS_PATH=/tmp/scala_buildpack_build_dir/vendor/node/bin/r.js
Next you have to enable the user-env-compile
lab from heroku. This will let you access any environment variables from the compilation process.
$ heroku labs:enable user-env-compile
After you complete the above steps, you can now push your latest changes to heroku and you will notice that the optimization step takes 10x less time
Upvotes: 4
Reputation: 1301
Add this to the project settings:
requireNativePath := Some("/usr/local/lib/node_modules/requirejs/bin/r.js")
You can also check out this sample app: https://github.com/magro/play2-java-computer-database/tree/master/play-coda
Upvotes: 2