几个月前我第一次接触webJars时,我非常怀疑它是否是处理客户端依赖关系的可行方式,因为某些构建/构建系统非常复杂,并且由于经常发布js
文件。第二个担忧当然是没有根据的,但是我在尝试让大约10个scss/css/less
类型的webJars和8个JS webJars共存于一个jsDependencies
下而花费了近36小时后感到自己被证明是正确的。
我发现的问题是,当你达到JS依赖项3、4或5时,你开始进入一个荒谬的时间消耗循环:
1. "哦,不!fastOptJS失败了,因为有一些随机文件也被命名为webjar中的某个依赖项!"
[trace] Stack trace suppressed: run last client/compile:resolvedJSDependencies for the full output.
[error] (client/compile:resolvedJSDependencies) org.scalajs.core.tools.jsdep.JSLibResolveException: Some references to JS libraries could not be resolved:
[error] - Ambiguous reference to a JS library: bootstrap.min.js
[error] Possible paths found on the classpath:
[error] - META-INF/resources/webjars/bootstrap/3.3.6/js/bootstrap.min.js
[error] - META-INF/resources/webjars/bootstrap3-dialog/1.34.4/examples/assets/bootstrap/js/bootstrap.min.js
[error] originating from: client:compile, client:compile, client:compile, client:compile
[error] - Ambiguous reference to a JS library: bootstrap.js
[error] Possible paths found on the classpath:
[error] - META-INF/resources/webjars/bootstrap3-dialog/1.34.4/examples/assets/bootstrap/js/bootstrap.js
[error] - META-INF/resources/webjars/bootstrap/3.3.6/js/bootstrap.js
[error] originating from: client:compile, client:compile, client:compile, client:compile
2. 我知道该怎么做!我会给定义的js添加一个版本!
lazy val webjarbs = "org.webjars" % "bootstrap" % version.bootstrap / s"${version.bootstrap}/bootstrap.js" minified s"${version.bootstrap}/bootstrap.min.js" dependsOn "jquery.js" commonJSName "bootstrap"
3. "哦不!fastOptJS失败了!"
[trace] Stack trace suppressed: run last client/compile:resolvedJSDependencies for the full output.
[error] (client/compile:resolvedJSDependencies) org.scalajs.core.tools.jsdep.JSLibResolveException: Some references to JS libraries could not be resolved:
[error] - Missing JS library: 3.3.6/bootstrap.js
[error] originating from: client:compile, client:compile, client:compile, client:compile
[error] - Missing JS library: 3.3.6/bootstrap.min.js
[error] originating from: client:compile, client:compile, client:compile, client:compile
GG男孩们。
这件事一遍又一遍、绕来绕去,然后我就不得不开始做。
lazy val bs_sidebar = ( "org.webjars" % "bootstrap-sidebar" % version.bs_sidebar intransitive()) / "js/sidebar.js" dependsOn(s"bootstrap.js", s"bootstrap.min.js")
现在我甚至没有使用 webjar,但它有一个名为 X 的js依赖项,我无法更改它...
问题
嗯?如果我只是像以前一样构建依赖项,将其构建成一个巨大的文件或一组文件,然后将其输入构建中呢?我从网上得到了一个概念验证,并使其工作(我认为是 https://github.com/wav/material-ui-scalajs-react/blob/master/src/main/scala/wav/web/muiwrapper/package.scala ),这几乎起作用,并给了我启发。
我知道npm
比sbt
好得多,而且我仍然可以将其放入我的软件包中...缺点是什么,我是否对sbt有所遗漏?
jsDependencies
更有原则的东西。npmDependencies
绝对是一个选择。 - sjrd