Feature request: JS/CSS-resources trough Webjars

It would be nice if I could add a Webjar dependency in build.gradle

dependencies {
    include "org.webjars:bootstrap:3.1.0"

…and then get access to the js-/css-files from the frontend.

<link rel="stylesheet" 
    data-th-href="${portal.webjarUrl({'_path=bootstrap/3.1.0/css/bootstrap.min.css'})}" />
1 Like

Hi Tom!

We agree - but we propose a slightly different approach:

dependencies {
    webjar "org.webjars:bootstrap:3.1.0"

And during the build process, we will simply copy the contents of META-INF/…resources/* into the assets folder instead?
That way we can use regular assetURL functions etc

Great if we could have a discussion on this - should be easy to add this to our 6.3 release (goes live this year)

1 Like

Yes, think that’s the best approach.

Actally, I have committed experimental webjar support in 6.2 that you can experiment on. It’s using the same format as @tsi wrote above.

1 Like

Just wanted to let you know that 6.2.0 is out and that contains an experimental “webjar” support.


I have just tested this for an upcoming starter kit, and it seems to be working as expected :slight_smile:


This is quite a nice feature. I’m updating Xeon to use webjars and I noticed that jQuery comes out with the wrong version. I put version 1.10.2 in build.gradle but it builds version 2.1.0. Everything else is working as expected.

Did you put anything else in there, like Bootstrap? Becouse if you add Bootstrap it will have a transitive dependency on JQuery. If this JQuery version is greater than the JQuery version you put in as a dependency, it will take the newest/greatest version. This is a standard “feature” of the build system and is not very easy to get around. It’s possible, but not recomended if you really do not need it.

To list all dependencies, you can run gradle dependencies.

I did some experimenting and you’re right. The org.webjars:isotope:1.5.26 requires jQuery 2.1.0 and when I comment that out then it builds the specified version. Nice to know about the gradle dependencies. I haven’t noticed any bugs from the newer version of jQuery so it’s probably best for me to stick with it. Thanks!

@tom - did it do the trick for you or should we do any adjustments?

1 Like

I have included webjars for:

  • bootstrap
  • angularjs
  • chartjs
  • angular-chart

And everything works as expected. No problems!

Thank you!


Great. Then we will “graduate” this feature :smile: