-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af547e5
commit 128ea35
Showing
9 changed files
with
168 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Builtin Plugins | ||
|
||
In addition to the [default plugins](./preset-default.md), the following plugins are available, but must be enabled with the [`--enable` command line option in order to be used: | ||
](./command-line-options.md#enable) | ||
|
||
- [round](./plugins/round.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Custom Configuration Files | ||
|
||
If you are using only the builtin plugins distributed with **svgo-ll**, you should be able to do all configuration from the [command line](./command-line-options.md), but if you are using custom plugins or have a complex configuration, you may want to use a custom configuration file. | ||
|
||
A custom configuration file is a JavaScript file that exports a [`Config` object](https://github.com/svg-utils/svgo-ll/blob/main/lib/svgo.d.ts), for example: | ||
|
||
```js | ||
import importedPlugin from './imported-plugin'; | ||
|
||
export default { | ||
plugins: [ | ||
// plugin imported from another JavaScript file | ||
importedPlugin, | ||
|
||
// plugin defined inline | ||
{ | ||
name: 'customPlugin', | ||
params: { | ||
paramName: 'paramValue', | ||
}, | ||
fn: (ast, params, info) => {}, | ||
}, | ||
], | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# minifyColors | ||
|
||
Rewrites color attributes and properties to use shorter formats. | ||
|
||
## Details | ||
|
||
The plugin has no effect if: | ||
|
||
- The document has scripts. | ||
- The document has `<style>` elements with CSS which **svgo-ll** is not able to process. | ||
- The `<style>` has attribute selectors. | ||
|
||
Depending on the format of the color specification, the color may be shortened as follows: | ||
|
||
- RGB colors in hexadecimal notation and [extended color keywords](https://www.w3.org/TR/css-color-3/#svg-color) are shortened to the shortest possible string (which may be a 6 character or 3 character hex string, or an extended color keyword). | ||
- RGB colors in `rgb()` functional notation using integer values are converted to 6 digit hexadecimal format, then shortened as above. | ||
- RGB colors in `rgb()` functional notation with percentage values, all of which are either `0%` or `100%`, are changed to integer values of 0 or 255, then shortened as above. | ||
- Color values in formats other than those described above are not changed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# round | ||
|
||
Rounds numbers to a shorter form. | ||
|
||
## Options | ||
|
||
- `coordDigits`: **number** - the number of digits after the decimal place to round x/y coordinates and width/height values (default: **4**) | ||
- `opacityDigits`: **number** - the number of digits after the decimal place to round opacity values (default: **3**) | ||
|
||
## Details | ||
|
||
The plugin has no effect if: | ||
|
||
- The document has scripts. | ||
- The document has `<style>` elements with CSS which **svgo-ll** is not able to process. | ||
- The document has `<style>` elements with attribute selectors. | ||
|
||
### x and y coordinates and width/height | ||
|
||
Coordinate values and lengths are rounded according to the context in which they are used. The number of digits to which a value is rounded is based on the `viewBox` context in which it is used (or if there is no `viewBox`, the `width` and `height`). The number of digits specified by the `coordDigits` parameter specifies the number of digits for a dimension >= 100 pixels and < 1000 pixels. Smaller dimensions will add one digit for each factor of 10, and larger dimensions will subtract one digit for each factor of 10. | ||
|
||
The following values are rounded using this value: | ||
|
||
- `M`, `m`, `L`, `l`, `H`, `h`, `V`, or `v` command values in the `d` attribute of a path element. | ||
- The coordinates in a `translate()` function in a `transform` attribute. | ||
- The `x`, `y`, `width` and `height` attributes of a `<rect>` element. | ||
- The `x1`, `y1`, `x2` and `y2` attributes of a `<line>` element. | ||
|
||
If the dimension of the element or its ancestors cannot be determined, or if the element or one of its ancestors is subject to a `transform` other than `translate()`, no rounding is done. | ||
|
||
### Opacities | ||
|
||
`opacity` and `fill-opacity` values are rounded to the number of digits specified by the `opacityDigits` parameter. | ||
|
||
### Colors | ||
|
||
Any colors specified using RGB percentages are converted to integer RGB values, and minified as they are in the [minifyColors](./minifyColors.md) plugin. |
Oops, something went wrong.