-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,9 @@ | ||
# Play Framework with Scala.js | ||
# Play Framework with Scala.js using a JavaScript Router | ||
|
||
[![License](http://img.shields.io/:license-Apache%202-red.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt) | ||
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/vmunier/play-with-scalajs-example?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) | ||
|
||
This is a simple example application showing how you can integrate a Play project with a Scala.js project. | ||
This is [play-with-scalajs-example](https://github.com/vmunier/play-with-scalajs-example) that has been modified to simply show how to use a JavaScript Router supporting Versioned Assets. | ||
|
||
The application contains three directories: | ||
* `server` Play application (server side) | ||
* `client` Scala.js application (client side) | ||
* `shared` Scala code that you want to share between the server and the client | ||
Issue on play-with-scalajs-example: https://github.com/vmunier/play-with-scalajs-example/issues/50 | ||
|
||
## Run the application | ||
```shell | ||
$ sbt | ||
> run | ||
$ open http://localhost:9000 | ||
``` | ||
|
||
## Features | ||
|
||
The application uses the [sbt-web-scalajs](https://github.com/vmunier/sbt-web-scalajs) sbt plugin and the [scalajs-scripts](https://github.com/vmunier/scalajs-scripts) library. | ||
|
||
- Run your application like a regular Play app | ||
- `compile` triggers the Scala.js fastOptJS command | ||
- `run` triggers the Scala.js fastOptJS command on page refresh | ||
- `~compile`, `~run`, continuous compilation is also available | ||
- Compilation errors from the Scala.js projects are also displayed in the browser | ||
- Production archives (e.g. using `stage`, `dist`) contain the optimised javascript | ||
- Source maps | ||
- Open your browser dev tool to set breakpoints or to see the guilty line of code when an exception is thrown | ||
- 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. | ||
|
||
## Cleaning | ||
|
||
The root project aggregates all the other projects by default. | ||
Use this root project, called `play-with-scalajs-example`, to clean all the projects at once. | ||
```shell | ||
$ sbt | ||
> play-with-scalajs-example/clean | ||
``` | ||
|
||
## IDE integration | ||
|
||
### Eclipse | ||
|
||
1. `$ sbt "eclipse with-source=true"` | ||
2. Inside Eclipse, `File/Import/General/Existing project...`, choose the root folder. Uncheck the second and the last checkboxes to only import client, server and one shared, click `Finish`. ![Alt text](screenshots/eclipse-play-with-scalajs-example.png?raw=true "eclipse play-with-scalajs-example screenshot") | ||
|
||
### IntelliJ | ||
|
||
In IntelliJ, open Project wizard, select `Import Project`, choose the root folder and click `OK`. | ||
Select `Import project from external model` option, choose `SBT project` and click `Next`. Select additional import options and click `Finish`. | ||
Make sure you use the IntelliJ Scala Plugin v1.3.3 or higher. There are known issues with prior versions of the plugin. | ||
Comment explaining how to use the Versioned JavaScript Router: https://github.com/playframework/playframework/issues/3435#issuecomment-57749755 |