I’m trying to import a javascript file in my Spring Boot/Vaadin project. I have tried every possible way but nothing works. I have created the following directories:
root/src/main/frontend/src/script.js should be the right location. Check that it’s getting loaded with the highly advanced alert("here") debugging technique
frontend/script.js or src/frontend/script.js (Vaadin locations)
But if you want to go dynamic or load from Java classpath, I’ve tried that easier with vaadin-js-loader. Basically allowing helper to load JavaScript from different places at runtime. Also useful if you want to allow e.g. overriding the JS library version later in inherited classes (which you cannot do with annotations).