Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to force Play Framework to compile all js files in only one via RequireJS?

Using Play-Framework 2.1(rc4) and the "built-in" RequireJS, everything works great, and Play successfully compress (uglify) all my JS files in PROD, but I'd like it to join all of them in one JS file.

Is this possible? If yes, how to do so ? Is there a build.js to make with these directives ?

like image 487
Cyril N. Avatar asked Feb 05 '13 09:02

Cyril N.


1 Answers

Yes it is possible.

You have to add the requireJsShim in the Build.scala file. Often, the value of requireJsShim is the same as the requireJs property.

Once you've done that, everything will be compiled in one file!

There is an example project for Play 2.1.0: https://github.com/schleichardt/play-2.1-features/tree/stackoverflow-question-14704169 (it is not in the master but in the stackoverflow-question-14704169 branch)

play dist

(! means in JAR or ZIP)

And dist/play-2-1-features-1.0-SNAPSHOT.zip!play-2-1-features-1.0-SNAPSHOT/lib/play-2-1-features_2.10-1.0-SNAPSHOT.jar!public/javascripts-min/main.js contains all JavaScript/CoffeeScript code.

like image 55
Schleichardt Avatar answered Sep 23 '22 15:09

Schleichardt