mirror of
https://github.com/PapirusDevelopmentTeam/papirus-icon-theme.git
synced 2024-10-18 09:10:34 -04:00
Add SVGO v2 config. Drop SVGO v1 support!
BREAKING CHANGE! This commit provides the new config file for svgo 2.0.0+ and removes the config file for svgo 1.3.2 and lower. To continue use tools in the project, please upgrade svgo to the latest version: npm install -g svgo
This commit is contained in:
parent
24665e6e0d
commit
c06ce6cc63
4 changed files with 119 additions and 142 deletions
|
@ -5,7 +5,7 @@
|
||||||
* `_clean_style_attr.sed` — removes unused properties and removes properties with default values from style attributes inside SVG files (part of `ffsvg.sh`)
|
* `_clean_style_attr.sed` — removes unused properties and removes properties with default values from style attributes inside SVG files (part of `ffsvg.sh`)
|
||||||
* `_fix_color_scheme.sh FILE...` — looks in the SVG files for certain colors and replaces them with the corresponding stylesheet class. Fixes a color scheme after Inkscape (part of `ffsvg.sh`)
|
* `_fix_color_scheme.sh FILE...` — looks in the SVG files for certain colors and replaces them with the corresponding stylesheet class. Fixes a color scheme after Inkscape (part of `ffsvg.sh`)
|
||||||
* `_scour.sh FILE...` — Scour wrapper (part of `ffsvg.sh`)
|
* `_scour.sh FILE...` — Scour wrapper (part of `ffsvg.sh`)
|
||||||
* `_svgo.yml` — [SVGO](https://github.com/svg/svgo) configuraion (part of `ffsvg.sh`)
|
* `svgo.config.js` — [SVGO](https://github.com/svg/svgo) configuraion (part of `ffsvg.sh`)
|
||||||
|
|
||||||
|
|
||||||
## Useful snippets
|
## Useful snippets
|
||||||
|
|
140
tools/_svgo.yml
140
tools/_svgo.yml
|
@ -1,140 +0,0 @@
|
||||||
# Default config for SVGO
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# for d in Papirus/16x16/* Papirus/22x22/* Papirus/24x24/*
|
|
||||||
# do
|
|
||||||
# svgo --config=_svgo.yml -f "$d"
|
|
||||||
# done
|
|
||||||
#
|
|
||||||
# or
|
|
||||||
#
|
|
||||||
# svgo --config=_svgo.yml -f Papirus/16x16/actions
|
|
||||||
#
|
|
||||||
# or
|
|
||||||
#
|
|
||||||
# svgo --config=_svgo.yml -i FILE
|
|
||||||
|
|
||||||
full: true
|
|
||||||
multipass: true
|
|
||||||
|
|
||||||
plugins:
|
|
||||||
|
|
||||||
# removes doctype declaration
|
|
||||||
- removeDoctype
|
|
||||||
|
|
||||||
# removes XML processing instructions
|
|
||||||
- removeXMLProcInst
|
|
||||||
|
|
||||||
# removes comments
|
|
||||||
- removeComments
|
|
||||||
|
|
||||||
# removes <metadata>
|
|
||||||
- removeMetadata
|
|
||||||
|
|
||||||
# removes editors namespaces, elements and attributes
|
|
||||||
- removeEditorsNSData
|
|
||||||
|
|
||||||
# removes unused IDs
|
|
||||||
# - cleanupIDs:
|
|
||||||
# minify: false
|
|
||||||
# preserve: [ 'current-color-scheme' ]
|
|
||||||
|
|
||||||
# removes elements in <defs> without id
|
|
||||||
- removeUselessDefs
|
|
||||||
|
|
||||||
# sorts element attributes (disabled by default)
|
|
||||||
- sortAttrs:
|
|
||||||
order:
|
|
||||||
- id
|
|
||||||
- fill
|
|
||||||
- stroke
|
|
||||||
- opacity
|
|
||||||
- style
|
|
||||||
- class
|
|
||||||
- width
|
|
||||||
- height
|
|
||||||
- x
|
|
||||||
- x1
|
|
||||||
- x2
|
|
||||||
- y
|
|
||||||
- y1
|
|
||||||
- y2
|
|
||||||
- cx
|
|
||||||
- cy
|
|
||||||
- rx
|
|
||||||
- ry
|
|
||||||
- r
|
|
||||||
- transform
|
|
||||||
- marker
|
|
||||||
- points
|
|
||||||
- d
|
|
||||||
|
|
||||||
# rounds numeric values to the fixed precision
|
|
||||||
# removes default ‘px’ units
|
|
||||||
# y="749.936002px" --> y="749.936"
|
|
||||||
- cleanupNumericValues:
|
|
||||||
floatPrecision: 3
|
|
||||||
leadingZero: true
|
|
||||||
defaultPx: true
|
|
||||||
convertToPx: false
|
|
||||||
|
|
||||||
# rounds list of values to the fixed precision
|
|
||||||
# viewBox="0 0 16px 16px" --> viewBox="0 0 16 16"
|
|
||||||
- cleanupListOfValues:
|
|
||||||
floatPrecision: 2
|
|
||||||
leadingZero: true
|
|
||||||
defaultPx: true
|
|
||||||
convertToPx: false
|
|
||||||
|
|
||||||
# converts colors: rgb() to #rrggbb
|
|
||||||
- convertColors:
|
|
||||||
shorthex: false
|
|
||||||
shortname: false
|
|
||||||
|
|
||||||
# convert non-eccentric <ellipse> to <circle>
|
|
||||||
- convertEllipseToCircle
|
|
||||||
|
|
||||||
# removes unknown elements content and attributes
|
|
||||||
# don't touch attrs with default values
|
|
||||||
# - removeUnknownsAndDefaults:
|
|
||||||
# defaultAttrs: false
|
|
||||||
|
|
||||||
# removes viewBox attr which coincides with a width/height box
|
|
||||||
- removeViewBox
|
|
||||||
|
|
||||||
# remove or cleanup enable-background attribute when possible
|
|
||||||
- cleanupEnableBackground
|
|
||||||
|
|
||||||
# removes hidden elements (zero sized, with absent attributes)
|
|
||||||
- removeHiddenElems:
|
|
||||||
opacity0: false
|
|
||||||
|
|
||||||
# removes empty <text> elements
|
|
||||||
- removeEmptyText
|
|
||||||
|
|
||||||
# removes empty attributes
|
|
||||||
- removeEmptyAttrs
|
|
||||||
|
|
||||||
# removes empty container elements
|
|
||||||
- removeEmptyContainers
|
|
||||||
|
|
||||||
# removes unused namespaces declaration
|
|
||||||
- removeUnusedNS
|
|
||||||
|
|
||||||
# removes <title>
|
|
||||||
- removeTitle
|
|
||||||
|
|
||||||
# removes <desc>
|
|
||||||
- removeDesc
|
|
||||||
|
|
||||||
# cleanups attributes from newlines, trailing and repeating spaces
|
|
||||||
- cleanupAttrs
|
|
||||||
|
|
||||||
# configure the indent (default 4 spaces) used by `--pretty` here:
|
|
||||||
#
|
|
||||||
# @see https://github.com/svg/svgo/blob/master/lib/svgo/js2svg.js#L6 for more config options
|
|
||||||
#
|
|
||||||
js2svg:
|
|
||||||
pretty: true
|
|
||||||
indent: ' '
|
|
|
@ -26,7 +26,7 @@ _run_helpers() {
|
||||||
# optimize a SVG
|
# optimize a SVG
|
||||||
if command -v svgo > /dev/null 2>&1; then
|
if command -v svgo > /dev/null 2>&1; then
|
||||||
# use SVGO
|
# use SVGO
|
||||||
svgo --config="$SCRIPT_DIR/_svgo.yml" -i "$1" -o "$1".tmp
|
svgo --config="$SCRIPT_DIR/svgo.config.js" -i "$1" -o "$1".tmp
|
||||||
mv -f "$1".tmp "$1"
|
mv -f "$1".tmp "$1"
|
||||||
elif command -v scour > /dev/null 2>&1; then
|
elif command -v scour > /dev/null 2>&1; then
|
||||||
# use scour
|
# use scour
|
||||||
|
|
117
tools/svgo.config.js
Normal file
117
tools/svgo.config.js
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
module.exports = {
|
||||||
|
multipass: true,
|
||||||
|
plugins: [
|
||||||
|
// remove DOCTYPE declaration
|
||||||
|
'removeDoctype',
|
||||||
|
// remove XML processing instructions
|
||||||
|
'removeXMLProcInst',
|
||||||
|
// remove comments
|
||||||
|
'removeComments',
|
||||||
|
// remove <metadata>
|
||||||
|
'removeMetadata',
|
||||||
|
// remove editors namespaces, elements and attributes
|
||||||
|
'removeEditorsNSData',
|
||||||
|
// cleanup attributes values from newlines, trailing and repeating spaces
|
||||||
|
'cleanupAttrs',
|
||||||
|
/**
|
||||||
|
* {
|
||||||
|
* // remove unused IDs
|
||||||
|
* name: 'cleanupIDs',
|
||||||
|
* params: {
|
||||||
|
* minify: false,
|
||||||
|
* preserve: ['current-color-scheme']
|
||||||
|
* }
|
||||||
|
* },
|
||||||
|
*/
|
||||||
|
// remove raster images references in <image>
|
||||||
|
'removeRasterImages',
|
||||||
|
// remove elements in <defs> without id
|
||||||
|
'removeUselessDefs',
|
||||||
|
{
|
||||||
|
// round numeric values to the fixed precision
|
||||||
|
// remove default 'px' units
|
||||||
|
// y="749.936002px" --> y="749.936"
|
||||||
|
name: 'cleanupNumericValues',
|
||||||
|
params: { convertToPx: false }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// round list of values to the fixed precision
|
||||||
|
// viewBox="0 0 16px 16px" --> viewBox="0 0 16 16"
|
||||||
|
name: 'cleanupListOfValues',
|
||||||
|
params: {
|
||||||
|
floatPrecision: 2,
|
||||||
|
leadingZero: true,
|
||||||
|
defaultPx: true,
|
||||||
|
convertToPx: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// convert different colors formats to #rrggbb
|
||||||
|
name: 'convertColors',
|
||||||
|
params: {
|
||||||
|
shorthex: false,
|
||||||
|
shortname: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* {
|
||||||
|
* // remove unknown elements content and attributes
|
||||||
|
* // don't touch attributes with default values
|
||||||
|
* name: 'removeUnknownsAndDefaults',
|
||||||
|
* params: { defaultAttrs: false }
|
||||||
|
* },
|
||||||
|
*/
|
||||||
|
// remove viewBox attr which coincides with a width/height box
|
||||||
|
'removeViewBox',
|
||||||
|
// remove or cleanup enable-background attribute when possible
|
||||||
|
'cleanupEnableBackground',
|
||||||
|
{
|
||||||
|
// remove hidden elements (zero sized, with absent attributes)
|
||||||
|
name: 'removeHiddenElems',
|
||||||
|
params: { opacity0: false }
|
||||||
|
},
|
||||||
|
// remove empty <text/>, <tspan/>, and <tref xlink:href=""/> elements
|
||||||
|
'removeEmptyText',
|
||||||
|
// convert non-eccentric <ellipse> to <circle>
|
||||||
|
'convertEllipseToCircle',
|
||||||
|
// remove attributes with empty values
|
||||||
|
'removeEmptyAttrs',
|
||||||
|
// remove empty containers
|
||||||
|
'removeEmptyContainers',
|
||||||
|
// remove unused namespaces declaration
|
||||||
|
'removeUnusedNS',
|
||||||
|
{
|
||||||
|
// sort element attributes for epic readability
|
||||||
|
name: 'sortAttrs',
|
||||||
|
params: {
|
||||||
|
order: [
|
||||||
|
'id',
|
||||||
|
'fill', 'stroke', 'opacity',
|
||||||
|
'style', 'class',
|
||||||
|
'width', 'height',
|
||||||
|
'x', 'x1', 'x2',
|
||||||
|
'y', 'y1', 'y2',
|
||||||
|
'cx', 'cy',
|
||||||
|
'rx', 'ry', 'r',
|
||||||
|
'transform',
|
||||||
|
'marker',
|
||||||
|
'points',
|
||||||
|
'd',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// remove <title>
|
||||||
|
'removeTitle',
|
||||||
|
// remove <desc>
|
||||||
|
'removeDesc',
|
||||||
|
// remove elements that are drawn outside of the viewbox
|
||||||
|
// 'removeOffCanvasPaths',
|
||||||
|
],
|
||||||
|
|
||||||
|
// configure the indent (default 4 spaces) used by `--pretty` here:
|
||||||
|
// @see https://github.com/svg/svgo/blob/master/lib/svgo/js2svg.js#L6 for more config options
|
||||||
|
js2svg: {
|
||||||
|
pretty: true,
|
||||||
|
indent: 1
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue