didi / booster

🚀Optimizer for mobile applications
https://booster.johnsonlee.io
Apache License 2.0
4.83k stars 576 forks source link

集成pngquant和cwebp后部分图片没有被转成webp #399

Closed healthyxth closed 1 year ago

healthyxth commented 1 year ago

工程中单独集成cwebp和同时集成pngquant和webp后包体积变化不大,偶尔甚至还变大了,不如单独集成cwebp。 后面发现第三方库的图片单独集成cwebp时会被转成webp格式,但是同时集成时第三方库的图片没有被转换成webp,只是被压缩了。 请问该怎么办才能让第三方库的图片先被pngquant压缩后转成webp格式?

healthyxth commented 1 year ago

build.gradle配置,booster版本4.15.0

classpath "com.didiglobal.booster:booster-gradle-plugin:$booster_version"
classpath "com.didiglobal.booster:booster-task-compression-pngquant:$booster_version"
classpath "io.johnsonlee.booster:booster-pngquant-provider:2.4.0"
classpath "com.didiglobal.booster:booster-task-compression-cwebp:$booster_version"

tasks.whenTaskAdded { task ->
    logger.warn("Task name=" + task.name)
    if (task.name == 'compressPrdReleaseResourcesWithCwebp') {
        task.mustRunAfter('compressPrdReleaseResourcesWithPngquant')
    }
}
johnsonlee commented 1 year ago

Please refer to : https://booster.johnsonlee.io/en/guide/shrinking/png-compression.html#getting-started