Using the asset pipline in Grails, the production CSS and Javascript files have been including with a digest appendix. This feature is not available in Spring Boot, therefore I started to create a simple Thymeleaf tag library.
The tag library simply contains two tag attribute processors with shared code to enable an automatic rewrite of src and href attributes:
Usage
<html xmlns:asset="https://www.itds.ch/taglib/asset">
<script asset:src="@{/assets/main.js}"></script>
<link asset:href="@{/assets/main.css}" rel="stylesheet"/>
</html>
The asset:src="@{/assets/main.js}"
will be replaced with src="/assets/main-DIGEST.js"
.
If the developmentRuntime is enabled and no manifest.properties exists or the manifest.properties contains no entry for a given file, the URL is not modified.
Required dependency
compile 'ch.itds.taglib:asset-pipeline-thymeleaf-taglib:1.0.0'
Required configuration
@Configuration
public class ThymeleafConfig {
@Bean
public AssetDialect assetDialect() {
return new AssetDialect();
}
}
The source is available on GitHub in itds-ch/asset-pipeline-thymeleaf-taglib