Skip to content

Commit

Permalink
- added description for new version
Browse files Browse the repository at this point in the history
- code refactoring
- fixed error when sass had tried to compile files in not an existing directory
  • Loading branch information
ShaggyYeti committed Aug 22, 2014
1 parent 4be0b52 commit 633c9c6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
sbt-sass for Play Framework 2.3.x
========
Plugin based on [play-sass][play-sass] for Play Framework 2.2.x
Plugin based on [play-sass][play-sass]

## ver 0.1.6 [23 aug 2014]
* Added support of sourcemaps generation, thanks to [@onelson][onelson]
* `--sourcemaps` parameter has hardcoded . It is absent in `sass` versions before `3.3`.

## ver 0.1.5 [02 aug 2014]
* Fixes #9 : added WebJars integration

## ver 0.1.4 [01 aug 2014]
* Fixes #8 : fixed incremental compilation issues (now dependencies compilation works)
* Improved sass command execution in Linux

# Prerequisites
[Sass][sass] compiler needs to be installed for plugin to work. This means that `sass` executable
needs to be found in path. Sass can be installed by by installing `sass` gem (version 3.2.19 is required by compass).
needs to be found in path. Sass can be installed by installing `sass` gem (**minimal version 3.3**).
```
gem install sass -v 3.2.19
gem install sass -v 3.4.0
```
You can verify that `sass` has been installed by following command:
```
Expand All @@ -30,7 +30,7 @@ gem install compass
```
resolvers += Resolver.url("GitHub repository", url("http://shaggyyeti.github.io/releases"))(Resolver.ivyStylePatterns)
addSbtPlugin("default" % "sbt-sass" % "0.1.5")
addSbtPlugin("default" % "sbt-sass" % "0.1.6")
```
2. Run `activator`

Expand All @@ -43,7 +43,7 @@ gem install compass
3. In sbt-console execute command `publishLocal`
4. Add line in your play project to project/plugins.sbt
```
addSbtPlugin("default" % "sbt-sass" % "0.1.5")
addSbtPlugin("default" % "sbt-sass" % "0.1.6")
```
5. Run `activator`

Expand Down Expand Up @@ -88,3 +88,4 @@ sassOptions in Assets ++= Seq("--compass", "-r", "compass")
[play-2.3-anatomy]: http://www.playframework.com/documentation/2.3.x/Anatomy
[issue6]: https://github.com/ShaggyYeti/sbt-sass/issues/6#issuecomment-49294238
[idea-env-vars]: http://www.jetbrains.com/idea/webhelp/path-variables-2.html
[onelson]: https://github.com/onelson
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sbtPlugin := true

name := "sbt-sass"

version := "0.1.5"
version := "0.1.6"

scalaVersion := "2.10.4"

Expand Down
2 changes: 1 addition & 1 deletion play-sass-example/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.0")

//resolvers += Resolver.url("GitHub repository", url("http://shaggyyeti.github.io/releases"))(Resolver.ivyStylePatterns)

addSbtPlugin("default" % "sbt-sass" % "0.1.5")
addSbtPlugin("default" % "sbt-sass" % "0.1.6")
10 changes: 7 additions & 3 deletions src/main/scala/sass/SbtSass.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object SbtSass extends AutoPlugin {

val baseSbtSassSettings = Seq(
sassEntryPoints <<= (sourceDirectory in Assets)(srcPath => ((srcPath ** "*.sass") +++ (srcPath ** "*.scss") --- srcPath ** "_*")),
// sassOptions := Seq.empty[String],
// include webjar folders
sassOptions := (webModuleDirectories in Assets).value.getPaths.foldLeft(Seq.empty[String]){ (acc, str) => acc ++ Seq("-I", str)},
resourceManaged in sass in Assets := (webTarget in Assets).value / "sass" / "main",
managedResourceDirectories += (resourceManaged in sass).value,
Expand All @@ -46,6 +46,10 @@ object SbtSass extends AutoPlugin {
val targetFileCssMin = (resourceManaged in sass).value / fileName.concat(".min.css")
val targetFileCssMinSourcemap = (resourceManaged in sass).value / fileName.concat(".min.css.map")

// prepares folders for results of sass compiler
targetFileCss.getParentFile().mkdirs()

// sass compiles and creates files
val dependencies = SassCompiler.compile(file, targetFileCss, targetFileCssMin, sassOptions.value)

val readFiles: Set[File] = (dependencies.map { new File(_) }).toSet + file
Expand All @@ -62,8 +66,8 @@ object SbtSass extends AutoPlugin {
}
}
val createdFiles = (compilationResults.map {_._1})
.foldLeft(Seq.empty[File]) { (files, pair) => files ++ Seq(pair._1, pair._2)}
val cachedForIncrementalCompilation = compilationResults.foldLeft(Map.empty[File, OpResult]) { (acc, e) => acc ++ Map((e._2, e._3))}
.foldLeft(Seq.empty[File]) { (createdFilesList, targetFiles) => createdFilesList ++ Seq(targetFiles._1, targetFiles._2)}
val cachedForIncrementalCompilation = compilationResults.foldLeft(Map.empty[File, OpResult]) { (acc, sourceAndResultFiles) => acc ++ Map((sourceAndResultFiles._2, sourceAndResultFiles._3))}
(cachedForIncrementalCompilation, createdFiles)
}
(results._1 ++ results._2.toSet).toSeq
Expand Down

0 comments on commit 633c9c6

Please sign in to comment.