Excluding Folders in Play Framework 2.2 dist

  • Post author:
  • Post category:Tools

We have a Play Framework 2.2 application that uses Gulp to optimize the public files. Gulp uses Node.js and it creates a public\node_modules directory. We don’t need the node_modules directory at runtime so we want to remove it when running the Play “dist” command.

1. In build.sbt, add the following lines.

mappings in (Compile, packageBin) ~= { _.filterNot { case (_, name) =>
	  name.startsWith("public\\node_modules")
}}

packageBin is the task that creates the project JAR under Compile scope. mappings are the files used during compilation and packaging. We filter out all the files that are under “public\node_modules”.

2. We also want to to remove the share folder. So we added the following lines in build.sbt as well.

doc in Compile <<= target.map(_ / "none")