There’s been more updates to the frontend plugin, so as of version 1.3 you can most certainly do everything that I originally set out.
- Using node + webpack as part of a Maven build process instead of hideous combinations of wro and others
- Changes to JS and LESS files automatically recompile
- The compiled changes are picked up immediately by Spring for use
- Changing one file shouldn’t make everything a source of neverending delay and pain
The answer here had a few components, not all of which I’m sure people will agree with, but here’s the breakdown.
https://github.com/eirslett/frontend-maven-plugin is a wonderful Maven plugin that takes care of point number one. It’s still under fairly active development, but as of 1.3, it integrates pretty easily into a Spring Boot application.
For point number 2 and 3, we need to be a bit more clever than I had originally been with the webpack config. Using
src/main/less as source directories plays nicely with maven and can be easily pulled into your IDE with a basic configuration of the maven resources plugin. In the webpack configuration, set those up to be the base input directory. If the base output directory happens to be
target\classes\META-INF\assets\, Spring Boot can pick up everything on the classpath and serve it under
assets automagically. Yes, I should have thought of this sooner.
You can keep the benefits of
frontend-maven-plugin by using a shared node folder between all your various frontend modules, so, it all maintains a single version of node that is shared and specific to your project. I’m going to keep playing with this, but the current setup I have is a far friendlier for getting things done (and spinning up new developers!) than anything else I’ve tried. In short?
spring boot =