A Dart package that optimizes SVG files at build time using SVGO.
Developed with 💛 by Droids On Roids ⚡
The goal of this package is to simplify the optimization of SVG files in Flutter projects using transformers.
Before package can be used, make sure to complete all of the prerequisites listed below.
- Install SVGO
- Make sure to add Node and SVGO to PATH environmental variable so that SVG Optimizer will be able to run them.
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
assets:
- path: assets/svg/
transformers:
- package: svg_optimizer
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.
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.