Is it possible to force the Play Framework to compile all js files only through RequireJS?

Using Play-Framework 2.1 (rc4) and the β€œbuilt-in” RequireJS, everything works fine, and Play successfully compresses (enlarges) all my JS files in PROD, but I would like to combine them all into one JS file,

Is it possible? If so, how to do it? Is there any build.js to do with these directives?

+7
source share
1 answer

Yes it is possible.

You must add requireJsShim to the requireJsShim file. Often, the value of requireJsShim matches the value of the requireJs property.

Once you do this, everything will be compiled into a single file!

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

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 the JavaScript / CoffeeScript code.

+2
source

All Articles