是否有可能通过WebJars使用我的应用程序中包含的Play 2.3应用程序concat/optimize JS(使用sbt-rjs)?
举一个具体的例子:我正在尝试创建一个core.js模块,其中包含在单个文件中连接和缩小的所有第三方库,然后可以将其指定为其他AMD模块的依赖项.
通过WebJars包含这些库而不是"手动"下载源会很棒.
这是我的build.sbt文件中的一个片段,我在其中指定了我的webjar依赖项:
// Webjars
libraryDependencies ++= Seq(
"org.webjars" % "requirejs" % "2.1.15",
"org.webjars" % "underscorejs" % "1.7.0",
"org.webjars" % "jquery" % "1.11.1",
"org.webjars" % "bootstrap" % "3.3.1" exclude("org.webjars", "jquery"),
"org.webjars" % "angularjs" % "1.3.4-1" exclude("org.webjars", "jquery")
)
Run Code Online (Sandbox Code Playgroud)
这是我的requireJS构建配置
requirejs.config({
baseUrl: '/assets/javascripts',
shim: {
'jsRoutes': {
deps: [],
exports: 'jsRoutes'
},
'angular': {
deps: ['jquery'],
exports: 'angular'
},
'underscore': {
exports: '_'
},
'angularRoute': ['angular'],
'angularCookies': ['angular'],
'bootstrap': ['jquery']
},
paths: {
'requirejs': …Run Code Online (Sandbox Code Playgroud) 我想知道如何在Play Framework 2.3+中使用CommonJS模块?
我想一个Browserify插件可以用类似于sbt-less插件的方式编写,但在开始之前我想知道其他人是如何处理它的.
在play框架构建过程中是否已经有一种方法可以使用Browserify?
我正在尝试使用sbt-web和sbt-js-engine特别是用npm而不是webjars来解析我的依赖关系.
我的问题是target/web/public/main/lib在web-stage任务期间不会将依赖项复制到文件夹中,因为使用webjar就是这种情况.
我使用sbt-js-engine的示例项目进行测试.有了这个项目,我希望console-browserify从package.json文件target/web/public/main/lib夹中的文件中找到依赖项,但事实并非如此.

也许我完全误解了什么?
几个月前,当我第一次发现webJars时,我非常怀疑,鉴于某些构建/构建系统的巨大复杂性以及js文件发布的频率,它将成为处理客户端依赖关系的可行方式.第二个问题当然不是很有根据,但是我在第一个问题上得到了证明,在花了差不多36个小时之后,现在徒劳地试图让10个scss/css/less类型的webJars和8个JS webJars生活在一个jsDependencies屋檐下.
我发现当你达到JS依赖3,4或5时,你开始进入一个荒谬的timekill循环:
[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] - …Run Code Online (Sandbox Code Playgroud) 我有一个多项目构建,我正在尝试将带有sbt-web生成的资产的jar添加到启动脚本的类路径中
我感兴趣的项目叫做website.
输入show website/web-assets:packageBinsbt会创建并显示带有资产的jar.我试过投入(managedClasspath in website) += website/web-assets:packageBin,但是没有编译:
path/to/build.sbt:58:error:value /不是sbt.Project的成员
网站中的managedClasspath + = website/web-assets:packageBin
如何在运行stage任务时创建带有资源的jar,并将其放在启动脚本的类路径中
(提供的示例项目)我无法让sbt-concat按照设计来查找和连接由可能从预处理器任务生成的样式产生的样式表.在我的生产应用程序中,我正在尝试使用它来捆绑来自sbt-sass的精选缩小的输出文件.它在该项目的复杂设置中不起作用,因此我创建了一个示例项目,看看我是否可以让它工作.它在示例项目中也不起作用.这是一个测试项目build.sbt,尝试创建几个包,几乎所有我能想到的可能性,只是为了看看它们是否有效(公共Github repo,你应该能够克隆并立即复制问题):
import com.typesafe.sbt.web.Import.WebKeys._
import com.typesafe.sbt.web.pipeline.Pipeline
name := """sbt-concat-test"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala, SbtWeb)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
ws
)
resolvers += Resolver.sonatypeRepo("releases")
includeFilter in (Assets, LessKeys.less) := "*.less"
excludeFilter in (Assets, LessKeys.less) := "_*.less"
val myPipelineTask = taskKey[Pipeline.Stage]("Some pipeline task")
myPipelineTask := { mappings => println(mappings); mappings }
pipelineStages := Seq(myPipelineTask, concat)
Concat.groups := Seq(
"style-group1.css" -> group(sourceDirectory.value ** "*.css"), …Run Code Online (Sandbox Code Playgroud) 我希望sbt设置在development(sbt run)中运行时具有与生产(sbt dist/ sbt start)不同的值.
具体来说我使用的是sbt-uglify.我在开发中使用它将javascript资产连接到一个文件中.我在开发中禁用了压缩和修改,因为它使代码更难调试.
在生产中,我想使用压缩来删除调试代码块(if (DEBUG) { ... }),这可能是使用uglifyjs的死代码删除功能.
我希望这可行:
// "in Assets" to use uglify in dev & prod
pipelineStages in Assets := Seq(uglify)
// enable compression and mangling in prod
UglifyKeys.compress := true
UglifyKeys.mangle := true
// disable in development (DOESN'T WORK! Values are always true)
UglifyKeys.compress in Assets := false
UglifyKeys.mangle in Assets := false
Run Code Online (Sandbox Code Playgroud) 我想使用这个插件
addSbtPlugin("net.ground5hark.sbt"%"sbt-concat"%"0.1.8")
连接我的资产.
我有3组:
Concat.groups := Seq(
"concat_main.css" -> group(Seq(
"stylesheets/bootstrap.min.css",
"stylesheets/font-awesome.css",
"stylesheets/totem/sidebar/component.css",
"stylesheets/main.min.css"
)),
"concat_main.js" -> group(Seq(
"javascripts/jquery-2.1.0.min.js",
"javascripts/bootstrap.min.js",
"javascripts/totemPage/sidebar/modernizr.custom.js",
"javascripts/totemPage/respond.min.js",
"javascripts/totemPage/html5shiv.js",
"javascripts/totemPage/sidebar/classie.js",
"javascripts/main.js"
)),
"concat_noel.js" -> group(Seq(
"javascripts/totemPage/ouibounce-modal.js",
"javascripts/ouibounce_modal.js",
"javascripts/homePage.js",
"javascripts/totemPage/jquery.cookie.js",
"javascripts/embed.js"
))
)
Concat.parentDir := "public/main/javascripts"
pipelineStages in Assets := Seq(concat, uglify, digest, gzip)
Run Code Online (Sandbox Code Playgroud)
文件是在dev中生成的,我可以访问
<link rel="stylesheet" href="@routes.Assets.versioned("javascripts/concat_main.css")">
<script src="@routes.Assets.versioned("javascripts/concat_main.js")" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
但是activator start我有一个404.