mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-31 13:45:09 +00:00
Provide gz version of web assets
This commit is contained in:
parent
8cb78e3dbe
commit
3b8500245f
25
build.sbt
25
build.sbt
@ -59,6 +59,7 @@ lazy val noPublish = Seq(
|
||||
val elmSettings = Seq(
|
||||
elmCompileMode := ElmCompileMode.Debug,
|
||||
Compile / resourceGenerators += Def.task {
|
||||
openapiCodegen.value
|
||||
compileElm(
|
||||
streams.value.log,
|
||||
(Compile / baseDirectory).value,
|
||||
@ -565,6 +566,18 @@ val root = project
|
||||
|
||||
// --- Helpers
|
||||
|
||||
def copyWithGZ(src: File, target: File): Seq[File] = {
|
||||
val gzipFilter = "*.html" || "*.css" || "*.js"
|
||||
IO.copy(Seq(src -> target))
|
||||
if (gzipFilter.accept(src)) {
|
||||
val gz = file(target.toString + ".gz")
|
||||
IO.gzip(src, gz)
|
||||
Seq(target, gz)
|
||||
} else {
|
||||
Seq(target)
|
||||
}
|
||||
}
|
||||
|
||||
def copyWebjarResources(
|
||||
src: Seq[File],
|
||||
base: File,
|
||||
@ -577,18 +590,16 @@ def copyWebjarResources(
|
||||
src.flatMap { dir =>
|
||||
if (dir.isDirectory) {
|
||||
val files = (dir ** "*").filter(_.isFile).get.pair(Path.relativeTo(dir))
|
||||
files.map {
|
||||
files.flatMap {
|
||||
case (f, name) =>
|
||||
val target = targetDir / name
|
||||
IO.createDirectories(Seq(target.getParentFile))
|
||||
IO.copy(Seq(f -> target))
|
||||
target
|
||||
copyWithGZ(f, target)
|
||||
}
|
||||
} else {
|
||||
val target = targetDir / dir.name
|
||||
IO.createDirectories(Seq(target.getParentFile))
|
||||
IO.copy(Seq(dir -> target))
|
||||
Seq(target)
|
||||
copyWithGZ(dir, target)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -611,7 +622,9 @@ def compileElm(
|
||||
)
|
||||
val out = proc.!!
|
||||
logger.info(out)
|
||||
Seq(target)
|
||||
val targetGZ = file(target.toString + ".gz")
|
||||
IO.gzip(target, targetGZ)
|
||||
Seq(target, targetGZ)
|
||||
}
|
||||
|
||||
def createWebjarSource(wj: Seq[ModuleID], out: File): Seq[File] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user