How to integrate npm/gulp/bower building process into sbt?

I have two separated git repos, one holds a scala server built with sbt, the other holds a webapp frontend built with npm/bower/gulp.

In server repo, I already have a task to build a standalone jar (not the standard package task) ; in frontend repo, I can build with npm install && npm run build which would result into a standalone directory _public .

Now I would like to include the UI directory _public during sbt building jar task, I am wondering if there is a better way to do so other than manually spawn external process in sbt to call npm ?


If your frontend uses NPM and Gulp to build the app, you need to run it with a NodeJS engine (or maybe JVM engines like Rhino or Nashorn can do it? not sure) and it requires an external process.

The question to ask yourself is: do you really want to couple the deployment of your backend from the deployment of your frontend? Isn't there any case where you simply want to deploy one and not the other?

I think using SBT to deploy you frontend is nice but if your frontend is complex, you'd rather keep it separate from SBT.

Your JS app does not necessarily need to be served as a Play public asset, you could simply deploy it to its own place and reference it inside a Play HTML template.


I agree with Sebastien to keep the front-end dev (and possibly even deploy) separate from your back-end, as I am in the process of learning that lesson myself.

That said, have a look at SbtWeb (task workflow) in tandem with WebJars (package management) . SbtWeb has several plugins that can cover the basics (uglify, concat, filter), and in some cases I think if node is installed it can use it directly.

链接地址: http://www.djcxy.com/p/82778.html

上一篇: 如何从python列表中获得n个最大的列表

下一篇: 如何将npm / gulp / bower构建过程整合到sbt中?