Skip to content

Instantly share code, notes, and snippets.

@guillaumebort
Created December 14, 2012 15:20
Show Gist options
  • Save guillaumebort/4286209 to your computer and use it in GitHub Desktop.
Save guillaumebort/4286209 to your computer and use it in GitHub Desktop.
Dynamically extracting SASS
val main = play.Project(appName, appVersion, appDependencies).settings(
resourceGenerators in Compile <+= (target, resourceManaged in Compile, cacheDirectory, streams) map { (target, resources, cache, streams) =>
val logger = streams.log
val sassWorkingDir = target / "sass-blabla"
if(!sassWorkingDir.exists) {
val maybeSass = this.getClass.getClassLoader.getParent.asInstanceOf[java.net.URLClassLoader].getURLs.map(_.getFile).map(file).find { file =>
logger.info(file.getAbsolutePath)
// check if it is the file we are looking for
false
}
maybeSass.map { zipFile =>
IO.unzip(zipFile, sassWorkingDir)
}.orElse {
sys.error("OOPS. missing SASS?")
}
}
// Here `sassWorkingDir` references a directory containing the whole SASS Stuff, so you can work with it and process resources as usual.
// ...
// The dynamically generated ressources (CSS) here as expected
Seq.empty[File]
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment