CoffeeScript 未在 Play 2.1.0 中编译

标签 coffeescript playframework-2.1

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

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

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

最佳答案

CoffeeScript doc 中所述:

Note that managed resources are not copied directly into your application’s public folder, but maintained in a separate folder in target/scala-2.x.x/resources_managed.



您必须通过 Assets 访问它使用反向路由的 Controller :
<script src="@routes.Assets.at("javascripts/main.js")">

关于CoffeeScript 未在 Play 2.1.0 中编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14820768/

相关文章:

coffeescript - 如何使用 CoffeeScript 创建另一个构造函数?

java - Play Framework 2.1 中的简单搜索?

scala - 处理 Scala Play 模板中的选项

scala - 在 play framework 2.1.1 中更改模板中的文本语言

json - 在 Play 2.1 Json Api 中获取异常行号?

ruby-on-rails - Rails 和 CoffeeScript 在生产环境中编译错误

javascript - Meteor,向单选按钮添加事件会禁用它们

javascript - 如何在 coffeescript 中执行 "if undefined"?

javascript - Gulp:同一任务中的不同 Pipe 集合(CoffeeScript 和 JavaScript)

playframework - 我的 Play 2.1.1 项目中的 .target 目录来自哪里?