2015-08-27 44 views
2

我正在使用圖標字體作爲圖標的java webapp。 我知道我可以使用IcoMoon應用程序從單個SVG文件創建圖標字體,但是我不想每次需要添加圖標時手動重新創建字體。 所以我想自動完成它,最好是作爲Maven構建的一部分。有沒有辦法讓Maven從各個SVG文件中生成圖標字體?使用Maven從SVG圖像生成圖標字體

回答

0

我不確定是否有maven插件來執行該特定功能。

我建議你使用咕嚕 http://gruntjs.com/ 運行在節點和繁重的Web字體插件 https://github.com/sapegin/grunt-webfont

如果您創建的SRC GruntFile.js /主/資源/咕嚕

module.exports = function(grunt) { 
//Project Configuration 
grunt.initConfig({ 
    pkg: grunt.file.readJSON('package.json'), //Details about the package were creating 
    webfont: { 
     icons: { 
      src : "icons/svg/*.svg", 
      dest: '../META-INF/resources/font', 
      destCss:'../META-INF/resources/css', 
      options: { 
       font: 'myfont', 
       fontFilename: 'MyFont', 
       types:'eot,woff,ttf,svg', 
       engine:'node', 
       stylesheet:'less', 
       htmlDemo:false 
      } 
     } 
    } 
}); 

grunt.loadNpmTasks('grunt-webfont'); 

grunt.registerTask('default', ['webfont']); 
}; 

然後你可以在你的pom中運行

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
      <artifactId>exec-maven-plugin</artifactId> 
      <version>1.4.0</version> 
      <executions> 
       <execution> 
        <id>Grunt run</id> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>exec</goal> 
        </goals> 
        <configuration> 
         <executable>grunt</executable> 
         <workingDirectory>${basedir}/src/main/resources/grunt</workingDirectory> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

您可能希望從maven資源中排除src/main/resources/grunt,並確保圖標文件不會通過maven資源篩選,因爲這樣可能會破壞它們。