margussipria / sbt-typescript   0.7.1

Apache License 2.0 GitHub

A plugin for SBT that uses sbt-web to compile typescript resources.

Scala versions: 2.12
sbt plugins: 1.x

sbt-typescript

License: Apache 2 Travis Build Maven Artifact

Allows TypeScript to be used from within sbt. Leverages the functionality of com.typesafe.sbt:js-engine to run the typescript compiler.

To use this plugin use the addSbtPlugin command within your project's plugins.sbt (or as a global setting) i.e.:

addSbtPlugin("eu.sipria.sbt" % "sbt-typescript" % "0.6.0")
resolvers += Resolver.typesafeRepo("releases")

You will also need to enable the SbtWeb plugin in your project.

By default, all typescript files (*.ts and *.tsx) are included in the compilation and will generate corresponding javascript files. In addition, if source map generation is enabled, the .ts and .tsx files will be copied to the output directory in order to make source maps work. To change this, supply an includeFilter in the TypescriptKeys.typescript task configuration.

The supported sbt settings are:

Option Description
configFile By default the sbt-typescript will look into the assets directory (app/assets/tsconfig.json). If you want sbt-typescript look into the root folder, just set this property to 'yourconfigname.json'
sourceRoot Specifies the location where debugger should locate TypeScript files instead of source locations.

include and exclude, baseUrl properties of tsconfig are not supported.

For including specific files of your project you can write something like:

Assets / typescript / includeFilter := GlobFilter("myFile.ts")

You can also set an exclude filter in the same way:

Assets / typescript / excludeFilter := GlobFilter("*.d.ts") | GlobFilter("*.spec.ts") | GlobFilter("**/typings")

A note on typescript compiling speed

Sometimes the default engine (Trireme) can be quite slow. If you're experiencing long typescript compile times you can always switch to node.js (remember to install it first) adding this line to your build.sbt file:

JsEngineKeys.engineType := JsEngineKeys.EngineType.Node