1

环境:玩2.3.10;sbt 0.13.5; sbt-rjs 1.0.1

我已经尝试了关于 play-framework Google group 和 StackOverflow 的类似问题的建议解决方案,但到目前为止还没有解决这个问题。我在Google Groups上发布了同样的问题。

我已将 Play 从 2.2.3 升级到 2.3.10 并在运行activator dist时收到以下错误:

[info] TypeError: Cannot read property 'normalize' of undefined

这是引发错误的代码行:

define([
    ...,
    'text!ui.template.html',
    ...
]

build.js包含以下内容:

require.config({
    ...
    ...
    paths : {
        ...,
        text: 'empty:',
        ...
    }
    ...
});

带有实际路径的config.js如下所示:

require.config({
    ...
    ...
    paths : {
        ...,
        text: '../bower_components/requirejs-plugins/lib/text',
        ...
    }
    ...
});

我希望 rjs 处理的所有脚本都在public/scripts中。下面是build.sbt的相关内容:

JsEngineKeys.engineType := JsEngineKeys.EngineType.Node

pipelineStages := Seq(rjs, digest, gzip)

includeFilter in rjs := new FileFilter {
  val scriptsDir = (baseDirectory.value / "public" / "scripts").getAbsolutePath
  def accept(file: File) = file.getAbsolutePath.startsWith(scriptsDir)
}

//excludeFilter in rjs := GlobFilter("text")

excludeFilter in rjs := new FileFilter {
  def accept(file: File) = file.getName.equals("text.js")
}

RjsKeys.mainModule := "app"

RjsKeys.mainConfigFile := new File("scripts/build.js")

RjsKeys.baseUrl := "scripts"

以下是plugins.sbt的内容:

// 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.10")

addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.1")

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

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

我根据此处的建议在 build.sbt 中添加了excludeFilter,并且还尝试了 rjs 中的 excludeFilter := GlobFilter("text.js")rjs := GlobFilter("text") 中的 excludeFilter

我还尝试按照此处的建议将stubModules : ['text']添加到 build.js 中。

如果我从 build.js 中删除文本:'empty:',我会收到以下错误:

[info] Error: ENOENT, no such file or directory '/path/to/target/web/rjs/build/scripts/text.js'

我将不胜感激任何指向我在这里缺少的东西。

谢谢。

4

0 回答 0