Using YUI Maven Mojo Compressor Reducing Javascript

I am working on a struts2 project using maven to compile. I am trying to minimize javascript files that are in different places.

<plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>yuicompressor-maven-plugin</artifactId>
    <version>1.3.0</version>
    <executions>
      <execution>
        <goals>
          <goal>compress</goal>
        </goals>
      </execution>
    </executions>        
    <configuration>
      <nosuffix>true</nosuffix>
    </configuration>
  </plugin>

I assume that in this case all js files will be reduced and replaced with the original file in the military war file (as defined by nosuffix).

However, this does not seem to be the case. How can I find out?

Secondly, if I decide to use one that has a suffix, I assume that I need to manually change the script link in my jsp files, is that correct? If so, how can I set it so that it deletes the original without a suffix?

Thank.

+2
source share
1

. pom.xml ( js css src/main/webapp):

    <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webResources>
                    <!-- Add minified resources -->
                    <resource>
                        <directory>${project.build.directory}/minimized</directory>
                        <targetPath>/</targetPath>
                        <filtering>false</filtering>
                    </resource>
                </webResources>
            </configuration>
        </plugin>

        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>yuicompressor-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>compress</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <nosuffix>true</nosuffix>
            </configuration>
        </plugin>
    </plugins>

    <pluginManagement>
        <plugins>
            <!-- Javascript and CSS files compression -->
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>yuicompressor-maven-plugin</artifactId>
                <version>1.1</version>
                <configuration>
                    <!-- Don't output in the default webapp location, since the war plugin will overwrite the files in there
                    with the original, uncompressed ones. -->
                    <webappDirectory>${project.build.directory}/minimized</webappDirectory>
                    <jswarn>false</jswarn>
                    <!-- Overwrite existing files -->
                    <nosuffix>true</nosuffix>
                    <includes>
                        <include>%path to your js and css files inside src/main/webapp%/**/*</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    </build>
+3

All Articles