繁体   English   中英

在Play 2.1.0中未编译CoffeeScript

[英]CoffeeScript is not compiled in Play 2.1.0

我正在Play 2.1.0中尝试使用CoffeeScript的第一步。 我创建了一个新应用程序,并将我的CoffeeScript文件main.coffee放置在app / assets / javascripts /中。

我希望在启动播放应用程序后(在播放控制台中输入“运行”),将编译我的CoffeeScript并将生成的main.js放置在public / javascripts目录中。

但是在该目录中没有创建main.js。 我是否必须在其他地方添加一些配置?

CoffeeScript文档所述

请注意,托管资源不会直接复制到应用程序的公用文件夹中,而是保留在target / scala-2.xx / resources_managed中的单独文件夹中。

而且您必须使用反向路由通过Assets控制器访问它:

<script src="@routes.Assets.at("javascripts/main.js")">

文档所述: CoffeeScript sources are compiled automatically during an assets command, or when you refresh any page in your browser while you are running in development mode.

因此,如果您不在development mode ,则应使用assets命令手动编译CoffeeScript。

在键入assets命令之前,通过在project/plugins.sbt文件中添加以下行,确保已在项目中添加了sbt-coffeescript插件:

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

通过添加上一行启用CoffeeScript编译后,进入项目的根目录并键入sbt命令。 sbt interact shell中,您可以键入assets命令,您将获得如下输出:

$ assets
[info] CoffeeScript compiling on 1 source(s)
[success] Total time: 4 s, completed May 30, 2015 9:43:29 PM

如您所见,CoffeeScript编译成功。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM