bertramdev / asset-pipeline

The core implementation of the asset pipeline for the jvm
193 stars 91 forks source link

Allow configuring warningLevel #277

Closed puneetbehl closed 2 years ago

puneetbehl commented 2 years ago

Add the ability to configure warnings for Closure Compiler. For instance in order to disable duplicate variable checks, update AssetPipelineExtension as following:

assets {
    minifyJs = true
    minifyCss = true
    minifyOptions = [
        warningLevel: [
            duplicate: "WARNING",
            checkVars: "WARNING"
        ]
    ]
}
puneetbehl commented 2 years ago

@davydotcom Could you please share which version include this fix?

davydotcom commented 2 years ago

3.4 should

niravassar commented 2 years ago

@davydotcom David, i tried to use classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.4" and also `runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails:3.4" in a grails 5 app and I am getting this error

   > Could not find com.bertramlabs.plugins:asset-pipeline-gradle:3.4.
     Searched in the following locations:
       - file:/C:/Users/nirav/.m2/repository/com/bertramlabs/plugins/asset-pipeline-gradle/3.4/asset-pipeline-gradle-3.4.pom
       - https://repo.grails.org/grails/core/com/bertramlabs/plugins/asset-pipeline-gradle/3.4/asset-pipeline-gradle-3.4.pom
     Required by:
         project :

This is my repo

maven { url "https://repo.grails.org/grails/core" }

can you tell what the issue is. I am trying to use the minify duplicates option with it off. Thanks.

niravassar commented 2 years ago

@davydotcom for the above comment, i needed to declare 3.4.0. Resolved. Thanks.

niravassar commented 2 years ago

I get this exception even if i use the config options with 3.4.0, and also 3.4.3

I used

assets {
    minifyJs = true
    minifyCss = true
    minifyOptions = [
            warningLevel: [
                    duplicate: "OFF",
                    checkVars: "OFF"
            ]
    ]
}

ERROR I get

Closure uglify JS Exception
asset.pipeline.processors.MinifyException: [JSC_BLOCK_SCOPED_DECL_MULTIPLY_DECLARED_ERROR. Duplicate let / const / class / function declaration in the same scope is not allowed. at com
monComponents-mf.unminified.js line 7225 : 25]
        at asset.pipeline.processors.ClosureCompilerProcessor.process(ClosureCompilerProcessor.groovy:81)
        at asset.pipeline.processors.ClosureCompilerProcessor$process$4.call(Unknown Source)
        at asset.pipeline.AssetCompiler$_compile_closure4.doCall(AssetCompiler.groovy:171)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

It doesnt seem to allow any duplicates at all and just fails. Is there a way to configure assetCompile to allow duplicates. I have a clinet app that has many and has it left over from grails 3.3.11 and now in grails 5.x every assetCompile is running into errors. What do you recommend.