【问题标题】:Declaring a different compile path for CoffeeScript为 CoffeeScript 声明不同的编译路径
【发布时间】:2012-11-28 00:01:18
【问题描述】:

我有一个 Scalatra 应用程序,它使用 https://github.com/softprops/coffeescripted-sbt 将 CoffeeScript 编译到默认位置 target/scala-2.9.1/resource_managed/main/js。我想将生成的 javascripts 放在一个公开可用的地方,在一个名为 src/main/webapp/coffee 的文件夹中,但给出的示例默认为 `/target/...'

resourceManaged in (Compile, CoffeeKeys.coffee)) <<= (crossTarget in Compile)(_ / "your_preference" / "js")

我的 build.sbt:

seq(coffeeSettings: _*)

// doesn't work
//(resourceManaged in (Compile, CoffeeKeys.coffee)) <<= ("src" / "main" / "webapp" / "coffee")

如果是src/main/webapp/coffeee,我将如何正确引用我希望编译资产进入build.sbt 内部的路径?

【问题讨论】:

    标签: scala coffeescript sbt scalatra


    【解决方案1】:

    添加到您的 build.sbt:

    //compiles your CoffeeScript files to resource_managed/main/webapp/js/
    (resourceManaged in (Compile, CoffeeKeys.coffee)) <<= (resourceManaged in Compile)(_ / "webapp" / "js")
    
    //makes ALL files in resource_managed/main/webapp as static file available
    com.github.siasia.PluginKeys.webappResources in Compile <+= (resourceManaged in Compile)(_ / "webapp" )
    

    src/main/coffee/example.coffee 将在http://localhost:8080/js/example.js 提供

    【讨论】:

    • 这不起作用。 在 servlet "" 上请求 "GET /resource_managed/main/webapp/file.js" 但只有:GET /
    • 对不起,更改了目录结构,但仍然没有找到参考。 返回与上述相同的错误。
    • 也许你需要绝对路径(路径以斜杠/开头)。你的咖啡文件在 src/main/coffee/anotherdirectory/example.coffee 中吗?
    • Schleichardt:感谢您的帮助。我们正在尝试您的 GIST,但仍然收到“找不到目录”错误。这是一个空白项目。我把它放在这里:dl.dropbox.com/u/2070388/hackapp.zip你看到我们做错了什么吗?
    • 实际上,这行得通……我们在项目中还有其他一些垃圾。很好的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多