Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play framework 2.3 dist task - javascripts-min not available

My PlayFramework (2.3) application works without a problem when running it in the development mode (sbt run). However when I try to create distribution (sbt dist) or star production (sbt start), javascript files are searched in minification folder (javascripts-min) which is not available. On the other hand, if using sbt-uglify, it creates minified version of javascripts, but in the same directory (main.min.js and main.js).

GET http://localhost:9000/assets/javascripts-min/main.js 404 (Not Found) 
GET http://localhost:9000/assets/javascripts/main.js (Ok)

Probably I need to configure something to make minification happen. Should I include some sbt plugin or change application configuration?

like image 501
Jure Polutnik Avatar asked Aug 19 '14 09:08

Jure Polutnik


1 Answers

I encountered the same problem, and for me the issue was that in the .scala.html file where I was loading the JavaScript file, I used @helper.requireJs like this:

@helper.requireJs(core = routes.Assets.at("javascripts/require.js").url,
  module = routes.Assets.at("javascripts/main.js").url)

Either @helper.requireJs is broken in Play Framework 2.3 or it's been deprecated, but it doesn't seem to work correctly any more. Replacing it with a regular <script> element solved the issue for me:

<script src="@routes.Assets.at("javascripts/require.js").url"
  data-main="@routes.Assets.at("javascripts/main.js").url"></script>
like image 163
Eero Helenius Avatar answered Nov 18 '22 12:11

Eero Helenius