Play 2.4.x - Assets duplication

穿精又带淫゛_ 提交于 2019-12-11 13:58:09

问题


In a Play 2.4.6 app I'm working on the assets are being duplicated in stage/dist tasks.

Basically it is a app with 3 submodules, with all the assets present in the main public folder. I don't have sbt-web enabled and have no webjars dependencies (but from the jar contents Play may be using them somewhere).

If I use PlayKeys.externalizeResources := false I end up with two jar files in the lib folder:

  • myapp-server.myapp-server-0.9.6-assets.jar
  • myapp-server.myapp-server-0.9.6.jar

The first one contains the assets, as it should. The 2nd should contain my main project class files, but it has also a META-INF/resources/webjars/myapp-server/0.9.6 folder containing every asset from the public folder!

If I use PlayKeys.externalizeResources := true I get the exact same behavior, but the extra META-INF/resources folder is present in myapp-server.myapp-server-0.9.6-externalized-resources.jar instead.

So how can I get rid of that extra assets folder? I have a lot of assets so that extra folder adds a lot to the package size...


回答1:


After some research, it seems that just excluding the extra folder from the "externalized" jar works:

mappings in (Compile, packageBin) ~= { (ms: Seq[(File, String)]) =>
    ms filterNot { case (file, dest) =>
        dest.contains("resources/webjars")
    }
}


来源:https://stackoverflow.com/questions/37598479/play-2-4-x-assets-duplication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!