Skip to content
Browse files

update readme and bump version

  • Loading branch information...
1 parent 34a2a27 commit 5e04082c19c0834f197acb5a81b16c36a507990a @casualjim casualjim committed Jul 20, 2012
Showing with 19 additions and 5 deletions.
  1. +16 −2 README.md
  2. +1 −1 build.sbt
  3. +2 −2 src/main/scala/org/scalatra/requirejs/RequireJsPlugin.scala
View
18 README.md
@@ -6,6 +6,10 @@ At this stage the plugin shells out to node.js so it does require node.js to be
[Installing Node.js](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager)
+[RequireJS optimization docs](http://requirejs.org/docs/optimization.html)
+
+[RequireJS documentation](http://requirejs.org/)
+
Adding the plugin:
```scala
@@ -35,6 +39,16 @@ mainConfigFile in (Compile, requireJs) <<=
(sourceDirectory in (Compile, requireJs), baseUrl in (Compile, requireJs))((a, b) => Some(a / b / "main.js"))
```
+The `buildProfile` key allows you to configure the r.js tool.
+All of the possible configuration options are discussed in this [example.build.js](https://github.com/jrburke/r.js/blob/master/build/example.build.js).
+Be sure to read the [require.js optimization docs](http://requirejs.org/docs/optimization.html) too.
+
+In addition to the buildProfile key the appDir, mainConfigFile, dir and baseUrl are configurable through sbt too.
+To configure the appDir you have to set the `sourceDirectory` key.
+To configure the dir you have to set the `target` key, the dir is an intermediate step for this plugin.
+To configure the mainConfigFile you have to set the `mainConfigFile` key.
+To configure the baseUrl you have to set the `baseUrl` key.
+
*Defaults*
```scala
@@ -44,8 +58,8 @@ webApp in requireJs <<= (sourceDirectory in c)(_ / "webapp")
// The location of the source files for the require.js app
sourceDirectory in requireJs <<= (sourceDirectory in c)(_ / "requirejs")
-// The location of the r.js file
-rjs in requireJs <<= (target in c)(_ / "r.js")
+// The location of the r.js file, when none is specified it uses the bundled version of r.js
+rjs in requireJs := None
// The location of the node.js binary
nodeBin in requireJs := ("which node" !!).trim
View
2 build.sbt
@@ -6,7 +6,7 @@ name := "sbt-requirejs"
organization := "org.scalatra.requirejs"
-version := "0.0.1-SNAPSHOT"
+version := "0.0.2-SNAPSHOT"
libraryDependencies ++= Seq(
"net.liftweb" %% "lift-json" % "2.4"
View
4 src/main/scala/org/scalatra/requirejs/RequireJsPlugin.scala
@@ -32,7 +32,7 @@ object RequireJsPlugin extends Plugin {
outputFile
}
private def unpackRjsFromResources(target: File) =
- copyFromClassPathToFilesystem("/requirejs/r.js", target / "r.js").getAbsolutePath
+ copyFromClassPathToFilesystem("/requirejs/r.js", target).getAbsolutePath
private def optimizeTask =
(target in requireJs,
@@ -41,7 +41,7 @@ object RequireJsPlugin extends Plugin {
includeFilter in requireJs,
excludeFilter in requireJs,
createBuildProfile in requireJs, streams) map { (tgt, rjsf, node, incl, excl, bp, log) =>
- val tool = rjsf.filter(_.exists).map(_.getAbsolutePath).getOrElse(unpackRjsFromResources(tgt))
+ val tool = rjsf.filter(_.exists).map(_.getAbsolutePath).getOrElse(unpackRjsFromResources(tgt / "r.js"))
val t = tgt.getAbsoluteFile
if (!t.exists()) IO.createDirectory(t.getAbsoluteFile)
val cmd = node + " " + tool + " -o " + bp.getAbsolutePath

0 comments on commit 5e04082

Please sign in to comment.
Something went wrong with that request. Please try again.