12

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 ?

ndeverge
  • 20,808
  • 4
  • 54
  • 84
  • Hi, sorry, I can't help you because I wasn't even able to get to the stage you are in. How did you manage to make get the `node_modules` folder appear? I had to manually run `sbt web-assets:jseNpmNodeModules` to fetch the npm dependencies. – tobik Mar 21 '15 at 15:33
  • I also had to run `sbt web-assets:jseNpmNodeModules` manually. – ndeverge Mar 21 '15 at 17:29
  • Hi, it seems to be an [issue](https://github.com/playframework/playframework/issues/3565) with playframework. Maybe try to upgrade to Play 2.4.2 and see if it is solved – Julien Boulay Sep 15 '15 at 21:26
  • @JulienBoulay thanks mate! I'll take a look :-) – ndeverge Sep 16 '15 at 06:10

1 Answers1

4

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

Wardrobe
  • 83
  • 1
  • 8