Play 2 Css / JS minifiaction and concatenation

Are there any built-in tools or plugins for storing all my page scripts in a single file? I found some topics in the mail playlist, but all of them have no answer to this question.

In addition, there is a google closure compiler somewhere deep, but it looks like no one but the infrastructure developers really knows how to make it work.

In any case, it will be enough if there are some tools that can at least merge all my css together in one file.

+5
source share
3 answers

Have you read the closing documentation ? It says:

JavaScript, /, Google Closure, , .

. .

+4

, javascript, minification gzipping Assets, . Play 2.2.1, , .

https://github.com/edeustace/assets-loader

+2

, RequireJS, Play. :  -  - RequireJS

Play 1.x , :

javascript/css ""

Play 2.x javascript. , javascript . css .

JavascriptRoutes script :

package controllers

import play.api.Play
import play.api.templates.Html

/**
 * Created by dnoz on 30/06/2014.
 */
object JavascriptRoutes {
  def javascriptRouter(scriptName :String): String = {
    val scriptFile = Play.getFile("app/assets/javascripts/" + scriptName)(Play.current)
    val bufferScriptFile = scala.io.Source.fromFile(scriptFile, "utf-8")
    val reformatedScriptContent = bufferScriptFile.mkString
    reformatedScriptContent
  }
}

script:

<script type='text/javascript'>
$(function(){
  @Html(JavascriptRoutes.javascriptRouter("backboneClasses/StoredObject/storedObject.model.js"))
  @Html(JavascriptRoutes.javascriptRouter("backboneClasses/Form/form.view.js"))

  //script specific to the view itself:
  var toto = new Object;
  //...
});
</script>

, script HTML . html gzip http-, ( ).

+1

All Articles