https://github.com/becklyn/svg-min
Minifies SVGs: applies transforms, remove attributes and runs SVGO on SVGs
https://github.com/becklyn/svg-min
Last synced: 3 months ago
JSON representation
Minifies SVGs: applies transforms, remove attributes and runs SVGO on SVGs
- Host: GitHub
- URL: https://github.com/becklyn/svg-min
- Owner: Becklyn
- License: bsd-3-clause
- Created: 2017-10-30T16:32:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-03T08:18:01.000Z (almost 6 years ago)
- Last Synced: 2025-01-14T03:13:58.805Z (4 months ago)
- Language: JavaScript
- Size: 29.3 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
svg-min
=======Minifies SVGs.
This small lib combines the following features:
* Applies transforms, so that the transforms are automatically absorbed into the paths.
* Removes unnecessary attributes.
* Moves the complete SVG, so that the origin is at `0 0`.
* Crops the artboard to only contain the actual object and no whitespace around it.
* Runs `SVGO`.Installation
------------```bash
npm -g i @becklyn/svg-min
```Usage
-----```bash
# will overwrite the original file
svg-min test.svg# will create the minified file in test.min.svg
svg-min test.svg --keep# will create the minified file in out.svg
svg-min test.svg out.svg# globs are also supported
svg-min *.svg# if your shell automatically replaces globs use
svg-min "*.svg"
```Caveats
-------
The implementation is pretty rudimentary and a lot of SVG features are not supported:* The script will bail if any `transform` except `translate` is used.
* The cropping of the artboard might fail.Testing
-------The test runner works with `ava`.
Just add your test case in `tests/fixtures/` with a descriptive name as `js` file:```js
module.exports = {
message: "This is a message describing the test case",
in: "...",
out: "...",
};
````message` is optional.
Run the tests with `npm test`.