Created
August 11, 2017 13:12
-
-
Save geowarin/26e0251a4ca8e8fb5dc7215708ec0139 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
class StaticResourceConfiguration( | |
val reactOptions: ReactOptions, | |
val webProperties: WebProperties | |
) : WebMvcConfigurerAdapter() { | |
override fun addResourceHandlers(registry: ResourceHandlerRegistry) { | |
val staticPaths = arrayOf( | |
"classpath:/static/", | |
reactOptions.staticBundleLocation | |
) | |
val resources = registry | |
.addResourceHandler("/**") | |
.addResourceLocations(*staticPaths) | |
.setCachePeriod(webProperties.cachePeriod) | |
if (webProperties.generateContentHash) { | |
val versionResolver = VersionResourceResolver() | |
versionResolver.addContentVersionStrategy("/**") | |
resources | |
.resourceChain(true) | |
.addResolver(versionResolver) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment