CoffeeScript not compiled in Play 2.1.0

I am trying to take the first steps with CoffeeScript in Play 2.1.0. I created a new application and placed my CoffeeScript main.coffee file in app / assets / javascripts /.

I expected that after starting the playback application (typing "run" in the game console, my compiler will be compiled and the resulting main.js file will be placed in the public / javascripts directory.

But main.js. is not created in this directory. Should I add some kind of configuration to another place?

+8
coffeescript
source share
2 answers

As stated in the CoffeeScript doc :

Please note that managed resources are not copied directly to the shared folder of your applications, but are saved in a separate folder in target / scala -2.xx / resources_managed.

And you should access it through the Assets controller using reverse routing:

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

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.

So, if you are not in development mode , you should use the assets command to compile your CoffeeScript manually.

Before entering the assets command, make sure you add the sbt-coffeescript plugin to your project by adding the following line to your project/plugins.sbt file:

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

After enabling CoffeeScript compilation, adding the previous line, change to the dorctory root directory and enter the sbt command. In the sbt command shell sbt you can enter the assets command, and you get some result like this:

 $ 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 compiles successfully.

+1
source share

All Articles