MIT License

项目介绍

sketch-hq/svgo-compressor 是一个托管在 GitHub 上的开源项目,主要使用 JavaScript 编写,采用 MIT License 许可证,目前获得 1.1k 个 Star、49 次 Fork。

仓库全名
sketch-hq/svgo-compressor
开源许可证
MIT License
Star 数
1.1k
Fork 数
49
未关闭 Issue
14

README 摘要

SVGO Compressor A Plugin that compresses SVG assets using SVGO, right when you export them. Install Download SVGO Compressor & unzip it. Double click SVGO Compressor.sketchplugin to install the Plugin. Usage Selecting menu items or hitting keys is out of fashion. SVGO Compressor will compress your SVG assets whenever you export them, without you having to do anything. You’ll get a message on your document window to…

完整内容见 GitHub 原始 README 或本页 。

常见问题

svgo-compressor 用什么语言开发?

主要使用 JavaScript 编写,采用 MIT License 许可证,目前有 1.1k 个 Star。

svgo-compressor 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 svgo-compressor 的源码?

可以直接克隆仓库:git clone https://github.com/sketch-hq/svgo-compressor.git,默认分支为 develop;安装与运行步骤见仓库 README。

svgo-compressor 最近还在维护吗?

仓库最近一次更新为 2023年1月6日,当前有 14 个未关闭 Issue;Star 数为 1.1k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

A Plugin that compresses SVG assets using SVGO, right when you export them.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
1268
价值分
685
活跃状态
活跃

README

SVGO Compressor

A Plugin that compresses SVG assets using SVGO, right when you export them.

Install

  • Download SVGO Compressor & unzip it.
  • Double click SVGO Compressor.sketchplugin to install the Plugin.

Usage

Selecting menu items or hitting keys is out of fashion. SVGO Compressor will compress your SVG assets whenever you export them, without you having to do anything.

You’ll get a message on your document window to let you know the compression worked as expected.

If you need uncompressed SVG assets, you can temporarily disable the Plugin by opening Sketch’s Preferences › Plugins and unchecking ‘SVGO Compressor’. Or you can right-click any layer and select Copy SVG Code, and that will give you the original, uncompressed code.

Custom SVGO configuration

SVGO Compressor uses a default configuration that does a reasonable job of compressing SVG code, while maintaining compatibility and avoiding rendering issues. If you need to change the defaults, you can do so by creating an svgo.config.js file in Sketch’s Plugins directory (located by default in ~/Library/Application\ Support/com.bohemiancoding.sketch3/Plugins/).

For a complete reference of what your SVGO config should look like, see SVGO’s configuration documentation.

Any option that is not set on your custom configuration will use the defaults set by SVGO Compressor. For example, here’s how a sample configuration to output unminified code could look like:

module.exports = {
  js2svg: {
    indent: 2,
    pretty: true,
  }
}

Keep in mind that our defaults do not match the ones in SVGO 100%. If you use the preset-default option in SVGO your results may vary from the ones this plugin exports. For the record, here’s the default configuration we use:

{
  path: currentFile, // This is the path to the currently exported SVG asset
  multipass: true,
  plugins: [
    {
      name: 'preset-default',
      params: {
        overrides: {
          inlineStyles: false,
          convertStyleToAttrs: true,
          cleanupListOfValues: true,
          removeViewBox: false,
          cleanupEnableBackground: false,
          removeHiddenElems: false,
          convertShapeToPath: false,
          moveElemsAttrsToGroup: false,
          moveGroupAttrsToElems: false,
          convertPathData: false,
          sortAttrs: true,
        }
      }
    }
  ],
}

Again, for more information about custom configurations please refer to SVGO’s own documentation. Please note that the custom plugins feature is untested in SVGO Compressor, so it may or may not work.

Acknowledgements

We would like to thank:

Development

This plugin is built using skpm. To build it, just run

npm i
npm run build

To edit the Plugin’s code, edit the code in src and run npm run build. You can also run npm run watch to automatically rebuild the Plugin every time you make changes in the code.

评论

暂无评论