Skip to content

Instantly share code, notes, and snippets.

@timperrett
Created April 29, 2015 20:01
Show Gist options
  • Save timperrett/ff6ba3bd011c02f024db to your computer and use it in GitHub Desktop.
Save timperrett/ff6ba3bd011c02f024db to your computer and use it in GitHub Desktop.
Using WebJars with Scala Unfiltered

Add the relevant webjars to your build file:

  libraryDependencies += "org.webjars.bower" % "angular" % "1.3.15"

Add the resources to your server definition:

unfiltered.netty.Server
  .http(8080)
  .resources(this.getClass.getResource("/www/"), cacheSeconds = 3600)
  .resources(this.getClass.getResource("/META-INF/resources/webjars"), cacheSeconds = 3600)
  .run

Then, assuming you have a file in your project resources/www/index.html, you can update the HTML to include the file:

...
    <script src="/webjars/angular/1.3.15/angular.min.js"></script>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment