Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play Framework 2.3.6 (Java) javascripts and stylesheets not found when deployed to Heroku

I have recently upgraded to Play Framework 2.3.6 (Java version) from version 2.2.x, following the migration guide. Locally, my app works as expected, but when deploying to Heroku, javascripts and stylesheets are missing from /assets/. My javascripts are located in public/javascripts/, and my stylesheets are generated from LESS files in app/assets/stylesheets/.

Both plugins.sbtand build.sbt have changed quite a lot after the switch to Play Framework 2.3.x, so I include both below. Maybe the error is somewhere to be found in there?

My plugins.sbt:

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.6")

// Use LESS
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.4")

// Use JSHint to validate javascript
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.1")

// Use RequireJS to (among other things) minify javascript
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.5")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.0.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-uglify" % "1.0.3")

My build.sbt:

import com.typesafe.sbt.less.Import.LessKeys
import play.PlayJava

name := "myApp"

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava,SbtWeb)

pipelineStages := Seq(rjs, digest, gzip)

scalaVersion := "2.11.1"

val appName = "myApp"
val appVersion = "1.0-SNAPSHOT"

javaOptions ++= Seq("-Xms128m", "-Xmx384m", "-Xss512k", "-XX:+UseCompressedOops")

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  javaWs,
  cache,
  "be.objectify" %% "deadbolt-java" % "2.3.1",
  "postgresql" % "postgresql" % "9.1-901-1.jdbc4",
  "com.feth" %% "play-easymail" % "0.6.6-SNAPSHOT",
  filters,
  "com.amazonaws" % "aws-java-sdk" % "1.8.9.1",
  "org.avaje.ebeanorm" % "avaje-ebeanorm" % "3.3.3",
  "com.typesafe.play" % "play-ebean-33-compat" % "1.0.0",
  "org.avaje.ebeanorm" % "avaje-ebeanorm-agent" % "3.2.2",
  "commons-io" % "commons-io" % "2.4",
  "net.sourceforge.htmlunit" % "htmlunit" % "2.15"
)

includeFilter in (Assets, LessKeys.less) := "*.less"

excludeFilter in (Assets, LessKeys.less) := "_*.less"

LessKeys.compress in Assets := true

dependencyOverrides += "org.avaje.ebeanorm" % "avaje-ebeanorm" % "3.3.3"

dependencyOverrides += "org.avaje.ebeanorm" % "avaje-ebeanorm-agent" % "3.2.2"

resolvers ++= Seq(
    Resolver.url("Objectify Play Repository", url("http://deadbolt.ws/releases/"))(Resolver.ivyStylePatterns),
    Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.com/snapshots/"))(Resolver.ivyStylePatterns),
    "play-easymail (release)" at "http://joscha.github.com/play-easymail/repo/releases/",
    "play-easymail (snapshot)" at "http://joscha.github.com/play-easymail/repo/snapshots/"
)
like image 264
plade Avatar asked Aug 25 '26 12:08

plade


1 Answers

Replace pipelineStages := Seq(rjs, digest, gzip) by pipelineStages := Seq(uglify, digest, gzip). Not sure why this works, but it worked for me.

like image 146
plade Avatar answered Aug 27 '26 03:08

plade



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!