primefaces-extensions / resources-optimizer-maven-plugin

Maven plugin to compress and merge web JS/CSS resources
Apache License 2.0
27 stars 15 forks source link

resources-optimizer-maven-plugin: Option `useDataUri` has no effect #142

Closed solomax closed 1 year ago

solomax commented 1 year ago

Describe the bug

Not sure if this is correct place for resources-optimizer-maven-plugin

The configuration like this:

<configuration>
    <useDataUri>false</useDataUri>
</configuration>

has no effect for version 2.6.0 (works as expected for 2.4.1

Reproducer

Steps:

Expected behavior

images should remain external

PrimeFaces Extensions version

2.6.0

JSF implementation

None

JSF version

No response

Browser(s)

No response

melloware commented 1 year ago

cc @VsevolodGolovanov looks like this broke with this change: https://github.com/primefaces-extensions/resources-optimizer-maven-plugin/issues/130

melloware commented 1 year ago

Hmm I am using it in Quarkus Faces: https://github.com/melloware/quarkus-faces/blob/a539276df90b25a849c55dff1341cbcb6f0c9f49/pom.xml#L215

and it seems to work?

solomax commented 1 year ago

Hello @melloware,

I'm very new to this plugin, trying to replace yuicompressor-maven-plugin with this one for Apache Wicket project

I've created very basic config:

<plugin>
    <groupId>org.primefaces.extensions</groupId>
    <artifactId>resources-optimizer-maven-plugin</artifactId>
    <version>${resources-optimizer-maven-plugin.version}</version>
    <configuration>
        <suffix>.min</suffix>
        <inputDir>${project.build.directory}/classes</inputDir>
        <useDataUri>false</useDataUri>
        <resourcesSets>
            <resourcesSet>
                <excludes>
                    <exclude>**/jquery*.js</exclude>
                </excludes>
            </resourcesSet>
        </resourcesSets>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>optimize</goal>
            </goals>
        </execution>
    </executions>
</plugin>

And was surprised with following lines in the log:

[INFO] Optimize CSS file theme.css ...
[INFO] Data URI conversion for: /home/solomax/work/wicket/wicket/wicket-extensions/target/classes/org/apache/wicket/extensions/markup/html/repeater/tree/theme/human/tree.gif
[INFO] Data URI conversion for: /home/solomax/work/wicket/wicket/wicket-extensions/target/classes/org/apache/wicket/extensions/markup/html/repeater/tree/theme/human/tree-rtl.gif

..............................

[INFO] === Statistic ===========================================
[INFO] Size before optimization = 109.604 KB
[INFO] Size after optimization = 112.353 KB
[INFO] Optimized resources have 102.51% of original size
[INFO] =========================================================

With 2.4.1 and same config I got much better results:

[INFO] === Statistic ===========================================
[INFO] Size before optimization = 109.604 KB
[INFO] Size after optimization = 49.72 KB
[INFO] Optimized resources have 45.36% of original size
[INFO] =========================================================
solomax commented 1 year ago

The real code is available here: https://github.com/apache/wicket/pull/602 :)

melloware commented 1 year ago

Definitely a bug that should not happen and the behavior in was correct in 2.4.1. Has to be the recent changes. Let me take a deeper look.

melloware commented 1 year ago

OK fixed it and let me push a 2.6.1 to Maven Central.

melloware commented 1 year ago

OK 2.6.1 is is Maven Central give it a shot and report back!

solomax commented 1 year ago

It was fast :))))

Thanks a lot! With version 2.6.1. everything works as expected!