Rename a generated file in Maven before building WAR

前端 未结 2 638
暗喜
暗喜 2021-01-14 08:49

Fingers crossed you can help me!

I am using SmartSprites to combine the PNGs on my landing page into one, so that it will load quicker.

SmartSprite will exam

相关标签:
2条回答
  • 2021-01-14 09:23

    You can use the Maven WAR plugin:

    <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
            <webResources>
                <resource>
                    <directory><!-- Your output directory --></directory>
                    <targetPath><!-- The target location of the files below --></targetPath>
                    <includes>
                        <include><!-- file pattern --></include>
                        <include><!-- file pattern --></include>
                    </includes>
                </resource>
            </webResources>
        </configuration>
    </plugin>
    

    You should also configure SmartSprites to use a different output directory to preserve the original CSS filename. Try the output-dir-path option with an empty css-file-suffix value.

    0 讨论(0)
  • 2021-01-14 09:33

    I'm afraid you won't find anything simpler or more elegant than Maven AntRun Plugin with something like this:

    <build>
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.7</version>
          <executions>
            <execution>
              <phase>prepare-package</phase>
              <configuration>
                <target>
                  <copy file="${project.build.directory}/mystyle-sprite.css"
                    tofile="${project.build.directory}/mystyle.css" />
                </target>
              </configuration>
              <goals>
                <goal>run</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
    
    0 讨论(0)
提交回复
热议问题