我最近在migration guide之后从版本2.2.x升级到Play Framework 2.3.6(Java版本)。在本地,我的应用程序按预期工作,但在部署到Heroku时,/assets/
缺少javascripts和样式表。我的javascripts位于public/javascripts/
,我的样式表是从app/assets/stylesheets/
中的LESS文件生成的。
切换到Play Framework 2.3.x后,plugins.sbt
和build.sbt
都发生了很大的变化,所以我在下面都包含了这两个内容。也许错误在那里可以找到?
我的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")
我的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/"
)
答案 0 :(得分:2)
将pipelineStages := Seq(rjs, digest, gzip)
替换为pipelineStages := Seq(uglify, digest, gzip)
。不知道为什么会这样,但它对我有用。