Search code examples
playframeworkplayframework-2.0typesafe-activator

activator dist: Not include managed resources (only their processed result)


How do I avoid the inclusion of managed resources, such as sass files from the zip output of activator dist? I manually deleted them from the target directory in my project such that my project now has no trace of scss files inside the target directory. But that still includes all the scss files in the assets jar inside the zip. Is there any way, manual or non-manual whereby I can avoid this?


Solution

  • Putting the below code in build.sbt is one way to exclude a directory:

    includeFilter in filter := new FileFilter {
      def accept(pathname: File): Boolean = {
        pathname.getAbsolutePath.contains("public/uploads/")
      }
    }
    
    pipelineStages := Seq(filter, digest, gzip)
    

    More explanation

    From https://github.com/sbt/sbt/blob/9ee8299383afb8c64f175acd9d3cb8648be519b6/util/io/src/main/scala/sbt/NameFilter.scala#L97

    A string is implicitly converted to GlobFilter. GlobFilter can be turned into either AllPassFilter, ExactFilter, and PatternFilter.

    These 3 filters inherits from NameFilter. And NameFilter only filters files/directories based on their names (not the whole absolute path).

    So, in a way, if you want to remove the directory "uploads", you can:

    includeFilter in filter := "uploads"
    

    I don't like this solution, it looks problematic to me because there might be multiple folders named "uploads". That's why I choose to implement my own FileFilter.