Skip to content

DroidsOnRoids/svg-optimizer

Repository files navigation

Flutter svg_optimizer Package

SVG Optimizer

A Dart package that optimizes SVG files at build time using SVGO.

Developed with 💛 by Droids On Roids

Droids On Roids logo

Overview

The goal of this package is to simplify the optimization of SVG files in Flutter projects using transformers.

Prerequisites

Before package can be used, make sure to complete all of the prerequisites listed below.

  1. Install SVGO
  2. Make sure to add Node and SVGO to PATH environmental variable so that SVG Optimizer will be able to run them.

Usage

Installation

To use this plugin, add svg_optimizer as a dependency in your pubspec.yaml file.

dev_dependencies:
  svg_optimizer: ^0.0.1+1

or run this command:

flutter pub add svg_optimizer 

Example usage

  assets:
    - path: assets/svg/
      transformers:
        - package: svg_optimizer

Running SVGO with custom configuration

To run svg_optimizer with custom SVGO configuration, add a config key with path to svgo.config.mjs file to the transformer's args in the pubspec.yaml file.

  assets:
    - path: assets/svg/
      transformers:
        - package: svg_optimizer
          args: ['--config=path/to/svgo.config.mjs']

For more information on SVGO configuration and customizing the config, refer to the SVGO documentation.

Benchmark

The package includes a benchmark utility to compare the size of the output file generated by flutter build with and without the svg_optimizer. To run the benchmark, use the command provided in the /benchmark directory documentation.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published