【发布时间】:2018-01-15 23:19:02
【问题描述】:
我正在使用 play framework 2.4 我的应用程序在安装 UI 组件之前运行良好,例如 (grunt,ruby,npm,cpmpass) 我对它们了解不多,但我的项目需要这些UI 工作有一个文件夹 node_modules 在 play 应用程序的 public 目录下,每当我给 run 或 test 命令时,这都会导致运行/测试项目的时间太多我见过很多正在开始在位置创建文件夹
playapp/target/web/classes/main/META-INF/resources/webjars/playapp/0.1.0-7708ad295b8fe2c87a28bdb6afa7c10401c12a61-SNAPSHOT/node_modules
我怎样才能避免这种情况? 以下是我尝试过的一些解决方案,但没有奏效
- https://www.playframework.com/documentation/2.4.x/SBTCookbook
- Include/Exclude asset folder/directory in sbt/play-framework
项目/咕噜声
import play.PlayRunHook
import sbt._
import java.net.InetSocketAddress
object Grunt {
def apply(base: File): PlayRunHook = {
object GruntProcess extends PlayRunHook {
var process: Option[Process] = None
override def beforeStarted(): Unit = {
Process("grunt dist", base).run
}
override def afterStarted(addr: InetSocketAddress): Unit = {
process = Some(Process("grunt watch", base).run)
}
override def afterStopped(): Unit = {
process.map(p => p.destroy())
process = None
}
}
GruntProcess
}
}
这里是 build.sbt 文件的一部分 编辑
import Grunt._
import play.PlayImport.PlayKeys.playRunHooks
import play.sbt.PlayImport.PlayKeys.playRunHooks
lazy val gruntDirectory = baseDirectory {
_ / "public"
}
excludeFilter := HiddenFileFilter -- ".tmp"
unmanagedResourceDirectories in Assets <+= gruntDirectory { _ / "dist"}
unmanagedResourceDirectories in Assets <+= gruntDirectory { _ / ".tmp"}
unmanagedResourceDirectories in Assets <+= gruntDirectory { _ / "bower_components"}
unmanagedResourceDirectories in Assets <+= gruntDirectory { _ / "node_modules"}
//this is for development environment
unmanagedResourceDirectories in Assets <+= gruntDirectory { _ / "src" / "app"}
playRunHooks <+= baseDirectory.map(base => Grunt(base))
但目标文件夹仍然充满了 node_modules 文件夹,该文件夹在 run 和 test 命令上创建了很多文件夹,请帮助。
编辑
我已经添加了
unmanagedResourceDirectories in Assets <+= gruntDirectory { _ / "node_modules"}
这一行,但现在我开始犯这个错误
[trace] Stack trace suppressed: run last playapp/web-assets:webExportedDirectory for the full output.
[error] (playapp/web-assets:webExportedDirectory) Duplicate mappings:
[error] playapp/target/web/classes/main/META-INF/resources/webjars/arteciate/0.1.0-7708ad295b8fe2c87a28bdb6afa7c10401c12a61-SNAPSHOT/requirejs/require.js
[error] from
[error] playapp/public/bower_components/requirejs/require.js
[error] /home/sara/git/arteciate/public/node_modules/requirejs/require.js
[error] playapp/target/web/classes/main/META-INF/resources/webjars/arteciate/0.1.0-7708ad295b8fe2c87a28bdb6afa7c10401c12a61-SNAPSHOT/requirejs/README.md
[error] from
[error] playapp/public/bower_components/requirejs/README.md
[error] playapp/public/node_modules/requirejs/README.md
[error] Total time: 5 s, completed Aug 8, 2017 5:09:17 PM
公共文件夹有以下内容
app bower.json dist Gruntfile.js node_modules README.md test
bower_components config fonts Gruntfile.js~ package.json _SpecRunner.html
我还想再问一个关于这些 UI 组件我不知道的问题,所以 UI 工具实际上是如何工作的,例如 npm, yeoman, bower, sass, grunt 以及 node_modules 是什么以及它们的用途和“我真的需要凉亭吗?使用 sbt 构建过程中的模块"
【问题讨论】:
-
你在哪里添加到跳过 node_modules 文件夹???
-
unmanagedResourceDirectories in Assets <+= gulpDirectory { _ / "node_modules"} -
请看我编辑的问题
-
它不是 graut,campass,它的 grunt 和 compass。
标签: scala npm playframework gruntjs sbt-0.13