Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
CssLinkResourceTransformer should not transform gzipped CSS files [SPR-14773] #19339
CssLinkResourceTransformer is not working if you are using gzipped CSS files. Here is a example configuration:
VersionResourceResolver versionResolver = new VersionResourceResolver().addContentVersionStrategy("/**"); registry .addResourceHandler(RESOURCES_PATH) .addResourceLocations("/resources/") .setCachePeriod(TWO_YEAR_IN_SECONDS) .resourceChain(true) .addResolver(new GzipResourceResolver()) .addResolver(versionResolver) .addResolver(new PathResourceResolver()) .addTransformer(new CssLinkResourceTransformer());
The links will not be modified within a CSS file, if you have a gzipped file. The problem is that the links could not be find due to this line in CssLinkResourceTransformer:
byte bytes = FileCopyUtils.copyToByteArray(resource.getInputStream());
If this is a gzipped file it should be decompressed first or if available the uncompressed version should be used.
Referenced from: commits cb44f27
Brian Clozel commented
This is now fixed.
Automatic resolution of gzipped resources is primarily for resources that should not be transformed at runtime. CSS files do not fall in that category. The goal of the
So your best bet here is to not pre-compress CSS files if you wish them to be transformed at runtime.
While looking at this I've found that the
Thanks for the report!