2

I have a Scalatra app that compiles CoffeeScript, using https://github.com/softprops/coffeescripted-sbt, to a default location, target/scala-2.9.1/resource_managed/main/js. I want to put the generated javascripts somewhere available to me publicly, in a folder called src/main/webapp/coffee, but the example given defaults to `/target/...'

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

My build.sbt:

seq(coffeeSettings: _*)

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

How would I reference the path I want the compiled assets to go into inside build.sbt correctly, if it's src/main/webapp/coffeee?

1 Answers1

1

add to your 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 will be available at http://localhost:8080/js/example.js

Schleichardt
  • 7,502
  • 1
  • 27
  • 37
  • This doesn't work. Requesting "GET /resource_managed/main/webapp/file.js" on servlet "" but only have: GET / –  Nov 28 '12 at 17:44
  • Sorry, changed the directory structures, but it still didn't find the reference. returns the same error above. –  Nov 28 '12 at 18:29
  • maybe you need the absolute path (path starts with slash /) . Is your coffee file in src/main/coffee/anotherdirectory/example.coffee? – Schleichardt Nov 28 '12 at 20:35
  • Schleichardt: Thanks for the help. We're trying out your GIST and still getting the "directory not found" error. It's a blank proj. I put it here: https://dl.dropbox.com/u/2070388/hackapp.zip Do you see something we are doing wrong? – kyleroche Nov 28 '12 at 21:41
  • Actually, this worked... we had some other junk in the project. Great answer. – kyleroche Nov 28 '12 at 21:55