Thoughts about Spring Boot + Thymeleaf + Javascript + Postgres Monolith
I have been experimenting with this development setup for a while, and one thing that we might forget is to handle the frontend Javascript code in which some business logic might be coded in there as well.
So I suppose the solution to the problem is to use a JS minifier.
I believe you can do an npm run build script before you package your jar to be deployed.
npm install uglify-js --save-devCreate a package.json
"scripts": {
"build": "uglifyjs src/main/resources/static/js/*.js -o src/main/resources/static/js/dist/bundle.min.js"
}Then run the build to minify/uglify your js code that contains the business logic
npm run build
Then include the final js file into your Thymeleaf html
<script th:src="/js/dist/bundle.min.js"></script>I believe every time you write your javascript business logic, you will need to run the build first before you deploy your app, or perhaps use Gradle’s build process to automate this step before running the app locally or deploy to the cloud.
