Created
September 26, 2015 22:55
-
-
Save asvanberg/eb0e24fd1113e22303eb to your computer and use it in GitHub Desktop.
Concatenate .coffee files before compiling to .js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy val concatCoffeeScript = taskKey[Seq[File]]("Concatenate .coffee") | |
lazy val concatCoffeeScriptFiles = settingKey[Seq[(String, Seq[String])]]("Files to concatenate, in order") | |
concatCoffeeScriptFiles := Seq( | |
"javascripts/app.coffee" → Seq("javascripts/product.coffee", "javascripts/person.coffee", "javascripts/main.coffee") | |
) | |
concatCoffeeScript <<= (sourceDirectory in Assets, concatCoffeeScriptFiles, WebKeys.webTarget) map { (d, fs, t) ⇒ | |
fs map { case (concatenated, parts) ⇒ | |
val cf = t / concatenated | |
IO.delete(cf) | |
IO.touch(cf) | |
parts map { d / _ } filter { _.exists } foreach { pf ⇒ | |
IO.append(cf, IO.readBytes(pf)) | |
IO.append(cf, "\n") | |
} | |
cf | |
} | |
} | |
import CoffeeScriptKeys._ | |
(unmanagedSources in (Assets, coffeescript)) <<= concatCoffeeScript | |
(unmanagedSourceDirectories in (Assets, coffeescript)) <+= WebKeys.webTarget | |
coffeescript <<= coffeescript dependsOn concatCoffeeScript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment