You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a spring boot /spring web app which contains some js and css assets.
When importing css files, spring boot does the right thing by mapping the used path to a path that contains a file hash. Great.
When my css files import other files, say font, spring boot does the right thing and update the path used ton use a version of thr same path which include file hash. Wonderfull.
When My html page import js script, spring boot, once again does the right thing Cooool.
But if my js files are js modules which require one another the the import path is not updated.
I've raised this issue previously and I remember being said that parsing js import is way more complexe than css import.
Which I understand and accept.
But I've found a way that could help to find a better way.
In html now we can define an import map, which will declare a mapping between a used path and a real one for our js assets.
This can be used to support fully js modules files with cross import and file name hash.
Since we can inject link with thymleaf, we can generate them completly with the hash.
Maybe a new form would need to be created to produce this import map and not always produce it.
Hope this will help advance the conversation.
The text was updated successfully, but these errors were encountered:
Given a spring boot /spring web app which contains some js and css assets.
When importing css files, spring boot does the right thing by mapping the used path to a path that contains a file hash. Great.
When my css files import other files, say font, spring boot does the right thing and update the path used ton use a version of thr same path which include file hash. Wonderfull.
When My html page import js script, spring boot, once again does the right thing Cooool.
But if my js files are js modules which require one another the the import path is not updated.
I've raised this issue previously and I remember being said that parsing js import is way more complexe than css import.
Which I understand and accept.
But I've found a way that could help to find a better way.
In html now we can define an import map, which will declare a mapping between a used path and a real one for our js assets.
This can be used to support fully js modules files with cross import and file name hash.
We can do it by hand, but I think that spring would be able to auto generate and inject that import map for us in the html pages.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap
Here is what I use
<script type="importmap" th:inline="javascript"> { "imports": { "turbo": "[(@{/webjars/hotwired__turbo/dist/turbo.es2017-esm.js})]", "stimulus": "[(@{/webjars/hotwired__stimulus/dist/stimulus.js})]", "chart-js": "[(@{/webjars/chartjs/dist/chart.esm.js})]", "luxon": "[(@{/webjars/luxon/build/es6/luxon.js})]" } } </script>Since we can inject link with thymleaf, we can generate them completly with the hash.
Maybe a new form would need to be created to produce this import map and not always produce it.
Hope this will help advance the conversation.
The text was updated successfully, but these errors were encountered: