Skip to content

Instantly share code, notes, and snippets.

@hexx
Created June 22, 2012 05:09
Show Gist options
  • Save hexx/2970364 to your computer and use it in GitHub Desktop.
Save hexx/2970364 to your computer and use it in GitHub Desktop.
play-jsx PlayJsxPlugin.scala
package com.github.hexx
import sbt._
import sbt.Keys._
object PlayJsxPlugin extends Plugin {
val jsxEntryPoints = SettingKey[PathFinder]("play-jsx-entry-points")
val jsxOptions = SettingKey[Seq[String]]("play-jsx-options")
val JsxCompiler = PlayProject.AssetsCompiler("jsx",
(_ ** "*.jsx"),
jsxEntryPoints,
{ (name, min) => name.replace(".jsx", if (min) ".min.js" else ".js") },
{ (jsxFile, options) => com.github.hexx.JsxCompiler.compile(jsxFile, options) },
jsxOptions
)
override val settings = Seq(
jsxEntryPoints <<= (sourceDirectory in Compile)(base => base / "assets" ** "*.jsx"),
jsxOptions := Seq.empty[String],
resourceGenerators in Compile <+= JsxCompiler
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment