Webjars

note

Webjars - 图1

This help topic is in development and will be updated in the future.

This feature enables serving static content provided by webjars. It allows you to package your assets such as javascript libraries and css as part of your uber-jar.

Installing the feature

  1. install(Webjars) {
  2. path = "assets" //defaults to /webjars
  3. zone = ZoneId.of("EST") //defaults to ZoneId.systemDefault()
  4. }

This configures the feature to serve any webjars assets on the /assets/ path. The zone argument configures the correct time zone to be used with the Last-Modified header to support caching (only if Conditional Headers feature is also installed).

Versioning support

Webjars allow developers to change the versions of the dependencies without requiring a change on the path used to load them on your templates.

Let’s assume you have imported org.webjars:jquery:3.2.1, you can use the following html code to import it:

  1. <head>
  2. <script src="/webjars/jquery/jquery.js"></script>
  3. </head>

You don’t need to specify a version, should you choose to update your dependencies you don’t need to modify your templates.