Created
June 13, 2012 07:50
-
-
Save davegurnell/2922624 to your computer and use it in GitHub Desktop.
Using the Untyped JS/Less plugins with Play 2.0 (sample SBT configuration)
This file contains 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
import sbt._ | |
import Keys._ | |
import PlayProject._ | |
import com.untyped.sbtjs.Plugin._ | |
import com.untyped.sbtless.Plugin._ | |
/* Example build config to use the Untyped JS/Less/Coffeescript plugins: | |
* | |
* http://github.com/untyped/sbt-plugins | |
* | |
* with Play 2.0: | |
* | |
* http://playframework.org | |
* | |
* The Untyped plugins are added to the build configuration | |
* alongside Play's built-in plugins. | |
* | |
* By using the Untyped plugins, you get a number of advantages | |
* including saner resolution of require/import filenames, | |
* CLASSPATH-style file searching, and build-time templating | |
* of JS/Less files. See the README files for more information: | |
* | |
* https://github.com/untyped/sbt-plugins/tree/master/sbt-js | |
* https://github.com/untyped/sbt-plugins/tree/master/sbt-less | |
*/ | |
object ApplicationBuild extends Build { | |
val appName = "playtest" | |
val appVersion = "1.0-SNAPSHOT" | |
val appDependencies = Seq( | |
// Add your project dependencies here, | |
) | |
val main = PlayProject( | |
appName, | |
appVersion, | |
appDependencies, | |
mainLang = SCALA | |
).settings( | |
jsSettings ++ | |
lessSettings ++ | |
Seq( | |
// Store your source files in app/static rather than app/assets, | |
// to avoid conflict with Play's built-in JS/Coffee/Less plugins. | |
// | |
// You can optionally have the plugins scan the public directory | |
// for additional sources, CLASSPATH style. This configuration | |
// searches static/javascripts first, then public/javascripts: | |
sourceDirectories in (Compile, JsKeys.js) <<= (sourceDirectory in Compile, baseDirectory)((src, base) => Seq( | |
src / "static" / "javascripts", | |
base / "public" / "javascripts" | |
)), | |
sourceDirectories in (Compile, LessKeys.less) <<= (sourceDirectory in Compile, baseDirectory)((src, base) => Seq( | |
src / "static" / "stylesheets", | |
base / "public" / "stylesheets" | |
)), | |
// I tend to build the minimum number of JS/CSS files per page | |
// by restricting the includeFilter to a single file. YMMV: | |
includeFilter in (Compile, JsKeys.js) := "site.js", | |
includeFilter in (Compile, LessKeys.less) := "screen.less", | |
// Put output files in the same place as Play does: | |
resourceManaged in (Compile, JsKeys.js) <<= (resourceManaged in Compile)(_ / "public" / "javascripts"), | |
resourceManaged in (Compile, LessKeys.less) <<= (resourceManaged in Compile)(_ / "public" / "stylesheets"), | |
// Make sure the plugins are called by the compile command and | |
// the continuous recompilation in the run command: | |
resourceGenerators in Compile <+= (JsKeys.js in Compile), | |
resourceGenerators in Compile <+= (LessKeys.less in Compile) | |
) : _* | |
) | |
} |
This file contains 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
resolvers ++= Seq( | |
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/", | |
Resolver.url("SBT Community", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns) | |
) | |
addSbtPlugin("play" % "sbt-plugin" % "2.0.1") | |
addSbtPlugin("com.untyped" %% "sbt-js" % "0.4") | |
addSbtPlugin("com.untyped" %% "sbt-less" % "0.4") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment