Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get sbt-web to work with npm for frontend dependencies

I'm trying to use sbt-web and sbt-js-engine in particular to resolve my dependencies with npm instead of webjars.

My problem is that the dependencies are not copied in the target/web/public/main/lib folder during the web-stage task as it is the case using webjar.

I used the sample project from sbt-js-engine to make my tests. With this project, I expect to find the console-browserify dependency from the package.json file in the target/web/public/main/lib folder, but it is not.

enter image description here

Maybe I'm completely misunderstanding something ?

like image 994
ndeverge Avatar asked Feb 01 '15 16:02

ndeverge


1 Answers

I've had a similar problem myself when trying to pulling some test dependencies with npm. after a few hour searching for a solution I ended up just writing a task in my build.sbt to move the directories manually: (May not be the best solution but a work around)

lazy val copy_node_modules = taskKey[Unit]("Copys the node_module to the test target dir")

copy_node_modules := {
  val node_modules = new File("node_modules")
  val target = new File("target/web/public/main/public/lib/")
  IO.copyDirectory(node_modules,target,true, true)
}

addCommandAlias("get_npm_deps", ";web-assets:jseNpmNodeModules;copy_node_modules")

then you can use "get_npm_deps" to pull in the npm based dependencies

like image 144
Wardrobe Avatar answered Nov 14 '22 13:11

Wardrobe