I am using play framework 2.4 my application was working fine before installing UI components e.g (grunt
,ruby
,npm
,cpmpass
)i did not know much about them but I needed these for my project UI
to work there is a folder node_modules
under the public
directory of the play app which is causing too much time to run/test the project whenever I gave run
or test
command I have seen lots of folders are being started to create at location
playapp/target/web/classes/main/META-INF/resources/webjars/playapp/0.1.0-7708ad295b8fe2c87a28bdb6afa7c10401c12a61-SNAPSHOT/node_modules
how can I avoid that? here are some solutions I have tried but it did not work
- https://www.playframework.com/documentation/2.4.x/SBTCookbook
- Include/Exclude asset folder/directory in sbt/play-framework
project/Grunt
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
}
}
here is the part of build.sbt file edit
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))
But still target folder get filled with node_modules folder which is creating lots of folder inside of it on run
and test
commands ,please help.
edit
i have added
unmanagedResourceDirectories in Assets <+= gruntDirectory { _ / "node_modules"}
this line but now i am gettig this error
[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
public folder has following contents
app bower.json dist Gruntfile.js node_modules README.md test
bower_components config fonts Gruntfile.js~ package.json _SpecRunner.html
and and i want to ask one more question i do not know about these UI componenets so how UI tools actually work like npm, yeoman, bower, sass, grunt
and, what are node_modules
and what they are used for and "do I actually need bower modules in my build process with sbt"