├── .gitignore ├── .travis.yml ├── README.md ├── build.sbt ├── index-fastopt.html ├── index.html ├── project ├── build.properties └── build.sbt └── src ├── main └── scala │ └── example │ └── ScalaJSExample.scala └── test └── scala └── example └── ScalaJSExampleTest.scala /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .cache 3 | .classpath 4 | .project 5 | .settings/ 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: scala 2 | script: 3 | - sbt ++$TRAVIS_SCALA_VERSION test 'set scalaJSStage in Global := FullOptStage' test 4 | scala: 5 | - 2.10.6 6 | - 2.11.8 7 | jdk: 8 | - oraclejdk8 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Barebone application written in Scala.js -- not maintained 2 | 3 | **This repository is not maintained anymore. 4 | Consider the [scala-js-tutorial](https://github.com/scala-js/scalajs-tutorial) repository instead, along with [the actual tutorial](https://www.scala-js.org/tutorial/basic/).** 5 | 6 | This is a barebone example of an application written in 7 | [Scala.js](http://www.scala-js.org/). 8 | 9 | ## Get started 10 | 11 | To get started, open `sbt` in this example project, and execute the task 12 | `fastOptJS`. This creates the file `target/scala-2.12/example-fastopt.js`. 13 | You can now open `index-fastopt.html` in your favorite Web browser! 14 | 15 | During development, it is useful to use `~fastOptJS` in sbt, so that each 16 | time you save a source file, a compilation of the project is triggered. 17 | Hence only a refresh of your Web page is needed to see the effects of your 18 | changes. 19 | 20 | ## Run the tests 21 | 22 | To run the test suite, execute the task `test`. If you have installed 23 | [Node.js](http://nodejs.org/), you can use that runtime to run the tests, 24 | which is faster: 25 | 26 | > set scalaJSStage in Global := FastOptStage 27 | > test 28 | 29 | ## The fully optimized version 30 | 31 | For ultimate code size reduction, use `fullOptJS`. This will take several 32 | seconds to execute, so typically you only use this for the final, production 33 | version of your application. While `index-fastopt.html` refers to the 34 | JavaScript emitted by `fastOptJS`, `index.html` refers to the optimized 35 | JavaScript emitted by `fullOptJS`. 36 | 37 | If Node.js is installed, the tests can also be run in their fully optimized 38 | version with: 39 | 40 | > set scalaJSStage in Global := FullOptStage 41 | > test 42 | -------------------------------------------------------------------------------- /build.sbt: -------------------------------------------------------------------------------- 1 | // Turn this project into a Scala.js project by importing these settings 2 | enablePlugins(ScalaJSPlugin) 3 | 4 | name := "Example" 5 | 6 | version := "0.1-SNAPSHOT" 7 | 8 | scalaVersion := "2.12.1" 9 | 10 | scalaJSUseMainModuleInitializer := true 11 | 12 | testFrameworks += new TestFramework("utest.runner.Framework") 13 | 14 | libraryDependencies ++= Seq( 15 | "org.scala-js" %%% "scalajs-dom" % "0.9.1", 16 | "com.lihaoyi" %%% "utest" % "0.4.5" % "test" 17 | ) 18 | -------------------------------------------------------------------------------- /index-fastopt.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |After having compiled and fast-optimized properly the code for the application 12 | (using `sbt fastOptJS`), you should see "It works" below. 13 | See README.md for detailed explanations.
14 | 15 |After having compiled and full-optimized properly the code for the application 12 | (using `sbt fullOptJS`), you should see "It works" below. 13 | See README.md for detailed explanations.
14 | 15 |