1

I am using the 'dist' command with play framework v2.5. However, when I unzip the file, it does not create the public directory. I have the following directories: bin, conf, lib, logs and share (contains doc).

Where should I place the public directory whereby this would work exactly like it does with the play framework (not having run the dist command) i.e. I can place static assets in the public directory and have them served from there (I do not wish to use a CDN for this purpose as of now).

I would ideally like the dist command to take care of it (as opposed to manually creating directories). Will the static route serve images from the public directory or do I need to write my own controller to serve these static assets?

ali haider
  • 19,175
  • 17
  • 80
  • 149

1 Answers1

3

As explained in this answer, add these lines into your /build.sbt file.

import com.typesafe.sbt.packager.MappingsHelper._
    mappings in Universal ++= directory(baseDirectory.value / "public")

That would include your 'public' directory inside the dist file (You can include any directory like that way). Then your application would work in the production environment.

Community
  • 1
  • 1
Supun Wijerathne
  • 11,964
  • 10
  • 61
  • 87
  • activator seems to be unable to load the file without issues - perhaps I need to revisit the build.sbt file - will update later, thanks – ali haider Jun 08 '16 at 14:37
  • I stopped using the public directory - and I have stopped using the dist command as well. I remember I had issues with activator with your suggestion - I will revisit when time permits and accept your answer - thank you so much – ali haider Oct 07 '16 at 16:49
  • @alihaider is this fine for you? ;) – Supun Wijerathne Jan 17 '19 at 04:45