google-code-export / wro4j

Automatically exported from code.google.com/p/wro4j
1 stars 1 forks source link

wro css url rewriting created incorrect urls #784

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Using the maven plugin to aggregate and pack my css and js 1.7.0
2. Configuration looks like

<plugin>
                        <groupId>ro.isdc.wro4j</groupId>
                        <artifactId>wro4j-maven-plugin</artifactId>
                        <version>${wro4j.version}</version>
                        <executions>
                            <execution>
                                <phase>compile</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <contextFolder>${project.build.directory}/${project.build.finalName}</contextFolder>
                            <jsDestinationFolder>${project.build.directory}/${project.build.finalName}/res/js/</jsDestinationFolder>
<cssDestinationFolder>${project.build.directory}/${project.build.finalName}/res/
css/</cssDestinationFolder>
                            <ignoreMissingResources>false</ignoreMissingResources>
                            <wroManagerFactory>ro.isdc.wro.extensions.manager.standalone.GoogleStandaloneManagerFactory</wroManagerFactory>

                        </configuration>

                        <dependencies>
                            <dependency>
                                <groupId>ro.isdc.wro4j</groupId>
                                <artifactId>wro4j-extensions</artifactId>
                                <version>${wro4j.version}</version>
                            </dependency>
                        </dependencies>

                    </plugin>

and in my wro.xml I have:

   <group name="show-mode">
        <css>/res/css/typography.css</css>
    </group>

typography.css contains:

.transparent-background {
    background-image: url("../images/transparent/transpixel.gif");
}

The filestructure looks like

/res/css
/res/js
/res/images/transparent/transpixel.gif

3.
In the show-mode.js that is produced in /res/css/ 
The background-image is rewritten to ../css/images/transparent/transpixel.gif

4. This is only happening on my windows 8 build slave and workstation, not on 
my primary OSX workstation. On OSX I get 
../../css/images/transparent/transpixel.gif that is correct if you want to 
rewrite it.

What is the expected output? What do you see instead?
On windows I get  ../css/images/transparent/transpixel.gif and not 
../../css/images/transparent/transpixel.gif as expected.

What version of the product are you using? On what operating system?
I have tried both in 1.6.4 and 1.7 on windows 8 and osx 10.8.5 with same 
result. 

Please provide any additional information below.
I have been reading about problems when rewriting paths in css files. Is there 
anyway to just turn it off? I have my source css files in the same directory as 
my aggregated and packed one, so my paths are correct from the beginning? 

Then I have notices that it does not matter what I put in cssDestinationFolder 
due respect for the rewriting! 
I would have thought if I output my css in 
${project.build.directory}/${project.build.finalName}/res/css/css/css/css/css/cs
s/css/ the image urls would be relative to this path. but it does not matter.

Thank you for a great package! Looking forward for your answer!

Best regards Andreas

Original issue reported on code.google.com by andr...@weightpoint.se on 16 Sep 2013 at 8:16

GoogleCodeExporter commented 9 years ago
Disabling cssUrlRewritingProcessor is easy. Just remove this preProcessor from 
the list of preProcessor. This can be achieved either extending the 
WroManagerFactory and overriding the ProcessorsFactory implementation, or using 
ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory and 
configuring processors in a properties file (wro.properties), example:

preProcessors=cssImport,jsMin,cssMin
postProcessors=lessCss,coffeeScript

You can find more details about this here: 
http://code.google.com/p/wro4j/wiki/MavenPlugin

The cssDestinationFolder is not used to compute the rewriting url, because it 
can be outside of the webapp folder, making it impossible to compute. However, 
it does make sense to take it into account when cssDestinationFolder is 
relative to webapp. This is something I could fix later as part of this issue.

By default the cssTargetFolder is located in a subfolder of webapp. Since you 
changed it to the root webapp folder, it does not work as expected. 

You have two options:
1) Change cssTargetFolder to a subfolder of webapp
2) Remove cssUrlRewritingProcessor (using custom WroManagerFactory or 
ConfigurableWroManagerFactory as described above).

Original comment by alex.obj...@gmail.com on 17 Sep 2013 at 6:52

GoogleCodeExporter commented 9 years ago
Actually the cssTargetFolder should be taken into account. Could you debug the 
Wro4jMojo#computeAggregatedFolderPath method? 

Use "mvnDebug wro4j:run"

What do you see?
If debugging doesn't help, creating a sample project I could use to debug the 
problem would help to fix this problem faster.

Thanks,
Alex

Original comment by alex.obj...@gmail.com on 18 Sep 2013 at 7:29