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?
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With