Hi,

minification can always be a problem, we ran into issues in other
frameworks / languages,  too...

Instead of disabling Minification for all files, or for a single browser,
you could also just replace the Google Closure compiler with a more
selective one:

https://gist.github.com/benweidig/db9d427c01c573b94cc5a492f88f7c39

public class CustomGoogleClosureMinimizer extends GoogleClosureMinimizer {

    public CustomGoogleClosureMinimizer(Logger logger,
                                        OperationTracker tracker,
                                        AssetChecksumGenerator
checksumGenerator,
                                        Request request,

@Symbol(WebResourcesSymbols.COMPILATION_LEVEL) CompilationLevel
compilationLevel) {
        super(logger, tracker, checksumGenerator, request,
compilationLevel);
    }

    @Override
    protected boolean isEnabled(StreamableResource resource) {

        if (resource.getDescription().endsWith("underscore-1.8.3.js")) {
            return false;
        }

        return super.isEnabled(resource);
    }
}


and overriding the original with

@Contribute(ResourceMinimizer.class)
@Primary
public static void
overrideGoogleClosureCompiler(MappedConfiguration<String,
ResourceMinimizer> conf,
                                                 @Autobuild
CustomGoogleClosureMinimizer gcm) {
    conf.override("text/javascript", gcm);
}

This way only the offending file won't be minimized, everything else will
be handled as usual.

I've debugged through a project of mine, it looked good for me.

To implement browser-related compression of a single file you would have to
go even earlier in the request (e.g. StreamableResourceSource).


Ben


On Thu, Oct 29, 2020 at 7:44 AM Hakan Sahin <sa...@avetana.de> wrote:

> Hi Volker,
>
> I do not want to disable minifaction at all. Maybe some other pieces of
> code can be effected.
>
> I like the idea from Ben as well and tried to integrate it within
> /contributeRequestHandler(OrderedConfiguration<RequestFilter> config,
> final RequestGlobals requestGlobals)/, with no success.
>
> Thank you both, I appreciate you took time for this "issue".
>
> Regards,
> Hakan
>
>

Reply via email to