你能帮我把我的托管资源添加到资产目标目录吗?
当我在我的 sbt 项目中运行 web-assets:assets 时,我的自动插件会生成一些 .css 和 .map 文件,但它不会立即将这些生成的资产添加到 web/public/main 目录中。只有当我再次运行 web-assets: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
}
非常感谢您对这个问题的关注。