你能帮我把我的托管资源添加到资产目标目录吗?
当我运行web资产:sbt项目中的资产时,我的自动插件会生成一些。css和。映射文件,但它没有
立即
将这些生成的资产添加到web/public/main目录。只有当我第二次运行webassets:assets时,这些资产才会被添加到web/public/main目录。
为什么在第一次访问时没有将这些资产添加到web/public/main目录,我能做些什么吗?
object SassPlugin extends AutoPlugin {
object autoImport {
object SassKeys {
val sassMake = TaskKey[Seq[File]]("sass-make", "Compile scss files.")
}
}
override def requires: Plugins = SbtWeb
override def trigger: PluginTrigger = AllRequirements
import SbtWeb.autoImport._
import WebKeys._
import autoImport.SassKeys._
val baseSassSettings = Seq(
resourceManaged in sassMake := webTarget.value / "sass",
sassMake := {
val sourceDir = (sourceDirectory in Assets).value / "stylesheets"
val targetDir = (resourceManaged in sassMake).value / "stylesheets"
val sources = (sourceDir ** "*.scss").get
val command =
Seq(
"c:\\Applications\\dart-sass-1.43.3-windows-x64\\dart-sass\\sass.bat",
Seq("--load-path=", baseDirectory.value, "\\node_modules").mkString,
sourceDir.absolutePath ++ ":" ++ targetDir.absolutePath
)
Process(command).run()
(targetDir ** ("*.css" || "*.map")).get
},
resourceGenerators += sassMake.taskValue
)
override def projectSettings: Seq[Def.Setting[_]] =
inConfig(Assets)(baseSassSettings
}
非常感谢您对这个问题的关注。