Code Monkey home page Code Monkey logo

sbt-play-scalajs's Introduction

sbt-play-scalajs

License Download Gitter

sbt-play-scalajs is a SBT plugin which allows you to use Scala.js along with Play Framework. It uses the sbt-web and scala-js plugins.

Setup

Specify the sbt version in project/build.properties which needs to be 0.13.5 or higher:

sbt.version=0.13.5

Add the sbt plugin to the project/plugins.sbt file along with Play! and Scala.js:

addSbtPlugin("com.vmunier" % "sbt-play-scalajs" % "0.2.6")

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.0")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.3")

Lastly, write the following configuration in build.sbt:

import sbt.Project.projectToRef

lazy val jsProjects = Seq(js)

lazy val jvm = project.settings(
  scalaJSProjects := jsProjects,
  pipelineStages := Seq(scalaJSProd)).
  enablePlugins(PlayScala).
  aggregate(jsProjects.map(projectToRef): _*)

lazy val js = project.enablePlugins(ScalaJSPlugin, ScalaJSPlay)

There are two auto-plugins: ScalaJSPlay and PlayScalaJS. The workflow is the following:

  • ScalaJSPlay plugin is enabled in Scala.js projects.
  • PlayScalaJS is added to Play project. It is build on top of SbtWeb plugin and can also add itself automaticly to all projects that have SbtWeb enabled.
  • Scala.js projects are collected in the scalaJSProjects setting key of the Play project.
  • When compilation or testing takes place, then the PlayScalaJS plugin runs all required tasks on scalaJSProjects projects, copies the output to Play assets and takes care about source maps.

To see the plugin in action, you can clone and run this simple example application.

Features

  • Use the scalaJSProjects setting key to attach several Scala.js projects to the Play! project
  • The scalaJSProd pipeline task generates the optimised javascript when running start, stage and dist
  • Source Maps is disabled in production by default to prevent your users from seeing the source files. But it can easily be enabled in production too by setting (emitSourceMaps in fullOptJS) := true in the Scala.js projects.
  • Use the sourceMapsDirectories setting on a Scala.js project to specify additional directories containing Scala files needed for Source Maps. You would typically use this setting when your Scala.js project depends on another Scala.js project.

sbt-play-scalajs's People

Contributors

vmunier avatar gitter-badger avatar antonkulaga avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.