[英]CoffeeScript is not compiled in Play 2.1.0
I am trying my first steps with CoffeeScript in Play 2.1.0. 我正在Play 2.1.0中尝试使用CoffeeScript的第一步。 I created a new application and placed my CoffeeScript file main.coffee in app/assets/javascripts/.
我创建了一个新应用程序,并将我的CoffeeScript文件main.coffee放置在app / assets / javascripts /中。
I expected that upon starting the play application (entering 'run' in the play console) my CoffeeScript would be compiled and the resulting main.js to be placed in the public/javascripts directory. 我希望在启动播放应用程序后(在播放控制台中输入“运行”),将编译我的CoffeeScript并将生成的main.js放置在public / javascripts目录中。
But no main.js gets created in that directory. 但是在该目录中没有创建main.js。 Do I have to add some configuration somewhere else?
我是否必须在其他地方添加一些配置?
As stated in the CoffeeScript doc : 如CoffeeScript文档所述 :
Note that managed resources are not copied directly into your application's public folder, but maintained in a separate folder in target/scala-2.xx/resources_managed.
请注意,托管资源不会直接复制到应用程序的公用文件夹中,而是保留在target / scala-2.xx / resources_managed中的单独文件夹中。
And you have to access it through the Assets
controller using reverse routing: 而且您必须使用反向路由通过
Assets
控制器访问它:
<script src="@routes.Assets.at("javascripts/main.js")">
As the documentation describes: 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.
如文档所述:
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.
So, if you are not in development mode
, you should use assets
command to compile your CoffeeScript manually. 因此,如果您不在
development mode
,则应使用assets
命令手动编译CoffeeScript。
Before type in the assets
command, make sure you have add the sbt-coffeescript
plugin in your project by adding the following line in your project/plugins.sbt
file: 在键入
assets
命令之前,通过在project/plugins.sbt
文件中添加以下行,确保已在项目中添加了sbt-coffeescript
插件:
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
After enable CoffeeScript compilation by adding the previous line, go into your project's root dirctory and type in sbt
command. 通过添加上一行启用CoffeeScript编译后,进入项目的根目录并键入
sbt
命令。 In the sbt
interact shell you can type in assets
command and you will get some output like this: 在
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
As you can see, CoffeeScript compile successfully. 如您所见,CoffeeScript编译成功。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.