untyped / sbt-plugins

SBT plugins for Javascript, Coffeescript, LESS, SASS, and Mustache compilation
73 stars 23 forks source link

Wrong scope for JS output dir: resourceManaged #29

Closed japgolly closed 11 years ago

japgolly commented 11 years ago

Before I start I want to make it clear that I'm near useless when it comes to SBT. I've read the doco, I don't really get it, I mostly get by by googling, copying, pasting and tweaking. That being said, if this is an error with me rather than sbt-js, I apologise.

What I'm trying to accomplish is sbt-js reading src/main/javascript/*.js and transforming them into <classpath>/js/*.js.

I've got it working with these settings:

// Put Javascript in WAR root
(webappResources in Compile) <+= (resourceManaged in Compile)

// Minify JS in src/main/javascript
(sourceDirectory in (Compile, JsKeys.js)) <<= (sourceDirectory in Compile)(_ / "javascript")

// Put minified JS in js/
(resourceManaged in (Compile,JsKeys.js)) <<= (resourceManaged in Compile)( _ / "js")

However the last line looks wrong to me. I think setting it that way will cause all managed resources to get a js/ prefix, which no one wants. If I change it to this:

// Put minified JS in js/
(resourceManaged in JsKeys.js) <<= (resourceManaged in Compile)( _ / "js")

it causes the minified JS to lose the js/ prefix again. May as well delete the line.

And that's what I think the bug here is. sbt-js should be relying on resourceManaged in JsKeys.js not resourceManaged in Compile, right?

davegurnell commented 11 years ago

I realise it's been a comical amount of time since this issue was posted, but...

You need to specify (resourceManaged in (Compile,JsKeys.js)) as mentioned. SBT is very finickity about scopes - anything less than an exact match and your code will have no effect.