SVG优化器Skill svg-optimizer

SVG优化器是一款用于前端开发的自动化工具,主要功能包括SVG图像压缩、精灵图生成和React/Vue组件转换。它能有效移除冗余元数据、优化路径结构、提升网页加载性能,并确保图标资源的可访问性,适用于构建现代Web应用和设计系统。关键词:SVG优化,前端开发,图标系统,React组件,性能优化,可访问性,精灵图生成,SVGO,svgr。

前端开发 0 次安装 14 次浏览 更新于 2/26/2026

name: svg-optimizer description: 优化SVG资源,生成精灵图,并转换为React组件 allowed-tools:

  • Read
  • Write
  • Edit
  • Bash
  • Glob
  • Grep

SVG优化器技能

目的

为Web和移动应用优化SVG资源,包括压缩、精灵图生成和React组件转换。

能力

  • 移除不必要的元数据和注释
  • 优化路径和形状
  • 为图标系统生成SVG精灵图
  • 将SVG转换为React/Vue组件
  • 压缩SVG文件大小
  • 确保可访问性属性(aria标签、角色)
  • 生成图标文档

目标流程

  • component-library.js (iconSystemDesignTask)
  • design-system.js

集成点

  • SVGO用于优化
  • svgr用于React组件生成
  • svg-sprite用于精灵图生成

输入模式

{
  "type": "object",
  "properties": {
    "inputPath": {
      "type": "string",
      "description": "SVG文件或目录的路径"
    },
    "outputPath": {
      "type": "string",
      "description": "输出目录"
    },
    "generateSprite": {
      "type": "boolean",
      "default": false
    },
    "generateComponents": {
      "type": "boolean",
      "default": false
    },
    "componentFormat": {
      "type": "string",
      "enum": ["react", "vue", "svelte"],
      "default": "react"
    },
    "optimizationLevel": {
      "type": "string",
      "enum": ["minimal", "standard", "aggressive"],
      "default": "standard"
    },
    "addAccessibility": {
      "type": "boolean",
      "default": true
    }
  },
  "required": ["inputPath"]
}

输出模式

{
  "type": "object",
  "properties": {
    "optimizedFiles": {
      "type": "array",
      "description": "优化后的SVG文件列表"
    },
    "spritePath": {
      "type": "string",
      "description": "生成的精灵图文件路径"
    },
    "componentPaths": {
      "type": "array",
      "description": "生成的组件路径"
    },
    "sizeSavings": {
      "type": "object",
      "description": "文件大小缩减统计"
    },
    "accessibilityReport": {
      "type": "object",
      "description": "添加的可访问性属性报告"
    }
  }
}

使用示例

const result = await skill.execute({
  inputPath: './icons',
  outputPath: './optimized-icons',
  generateSprite: true,
  generateComponents: true,
  componentFormat: 'react',
  addAccessibility: true
});