devsoap/ds-gradle-vaadin

Production mode Java Script

Closed this issue · 2 comments

  1. Add dependencies
    implementation 'org.webjars.bower:jquery:3.3.1'
  1. Import JS
<link rel="import" href="../../../bower_components/3.3.1/dist/jquery.min.js">

or

@JavaScript("frontend://bower_components/3.3.1/dist/jquery.min.js")

The problem is that in development mode. The right way

frontend://bower_components/3.3.1/jquery/dist/jquery.min.js

But in production mode

frontend://bower_components/3.3.1/dist/jquery.min.js

The second problem when I add JS such

<link rel="import" href="../../bower_components/d3/5.7.0/d3.min.js">

I have error
image

I must explicitly specify the script tag.
With @JavaScript all work well.

Looks like the jquery webjar is not unpacked correctly. It should be unpacked to ../build/frontend/bower_components/jquery/dist/jquery.min.js.