使用sbt

时间:2016-12-23 02:03:59

标签: node.js npm sbt npm-install

所以我有一个使用sbtsbt-js-engine插件的sbt-webpack项目。

它成功获取并解析了npm包就好了。然后webpack将构建项目。

我已将{npm安装脚本添加到package.json中,如此,

  "scripts": {
    "install": "bower install"
  }

但是,我目前遇到的问题是,当我运行webpack(实习生使用sbt-js-engine )时,它会运行npm update而不是npm install

以下是build.sbt的摘录,

lazy val common = project.in(file("common")).
  enablePlugins(SbtWeb).
  settings(
    sourceDirectory in webpack := baseDirectory.value,
    resourceManaged in webpack := (resourceManaged in webpack in root).value,
    includeFilter in webpack := ("*.jsx" || "*.js" || "*.json") && new FileFilter {
      @tailrec
      override def accept(pathname: File): Boolean = {
        if (pathname == null) false
        else if (pathname.getName == "javascripts") true
        else accept(pathname.getParentFile)
      }
    },
    JsEngineKeys.engineType := JsEngineKeys.EngineType.Node
  )

无论如何我可以代替甚至之前运行npm install作为webpack任务的依赖吗?

1 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

sourceDirectory in webpack := {
    Process("/usr/local/bin/npm install", file("[path to working dir]")).!
    baseDirectory.value
}

这意味着它会在设置webpack设置的同时运行。