问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/36704962/where-to-place-the-public-directory-for-play-framework-after-using-the-dist-comm