1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2024-11-26 01:00:27 +02:00
simple-icons/svgo.config.mjs

110 lines
2.5 KiB
JavaScript
Raw Normal View History

2024-06-06 14:40:35 +02:00
/**
* @file SVGO configuration for Simple Icons.
*/
/** @type {import("svgo").Config} */
2024-03-24 19:38:18 +02:00
const config = {
multipass: true,
plugins: [
2021-11-29 19:59:11 +02:00
'cleanupAttrs',
'inlineStyles',
'removeDoctype',
'removeXMLProcInst',
'removeComments',
'removeMetadata',
'removeDesc',
'removeUselessDefs',
'removeEditorsNSData',
'removeEmptyAttrs',
'removeHiddenElems',
'removeEmptyText',
'removeEmptyContainers',
'cleanupEnableBackground',
{
2021-11-29 19:59:11 +02:00
name: 'convertPathData',
params: {
2021-11-29 19:59:11 +02:00
// 3 decimals of precision in floating point numbers
floatPrecision: 3,
// Some editors (e.g. Adobe Illustrator and Sketch) cannot parse flags
// without space wrapping
noSpaceAfterFlags: false,
},
},
2021-11-29 19:59:11 +02:00
'convertTransform',
{
name: 'removeUnknownsAndDefaults',
params: {
// Keep the 'role' attribute, if it's already defined
keepRoleAttr: true,
},
},
'removeNonInheritableGroupAttrs',
{
// Remove paths with fill="none"
name: 'removeUselessStrokeAndFill',
params: {
removeNone: true,
},
},
'removeUselessStrokeAndFill',
'removeUnusedNS',
'cleanupIds',
2021-11-29 19:59:11 +02:00
'cleanupNumericValues',
'cleanupListOfValues',
'moveGroupAttrsToElems',
'collapseGroups',
'removeRasterImages',
{
// Compound all <path>s into one
name: 'mergePaths',
params: {
force: true,
noSpaceAfterFlags: false,
},
},
{
// Convert basic shapes (such as <circle>) to <path>
name: 'convertShapeToPath',
params: {
2024-03-24 19:38:18 +02:00
// Including <arc>
2021-11-29 19:59:11 +02:00
convertArcs: true,
},
},
'convertEllipseToCircle',
{
// Sort the attributes on the <svg> tag
name: 'sortAttrs',
params: {
order: ['role', 'viewBox'],
xmlnsOrder: 'alphabetical',
2021-11-29 19:59:11 +02:00
},
},
'sortDefsChildren',
'removeDimensions',
{
name: 'removeAttrs',
params: {
attrs: [
'svg:.*(?<!((role)|(viewBox)|(xmlns)))',
'path:(?!d)',
'title:*',
],
2021-11-29 19:59:11 +02:00
},
},
{
// Keep the role="img" attribute and automatically add it
// to the <svg> tag if it's not there already
name: 'addAttributesToSVGElement',
params: {
2024-03-24 19:38:18 +02:00
attributes: [{role: 'img', xmlns: 'http://www.w3.org/2000/svg'}],
2021-11-29 19:59:11 +02:00
},
},
'removeOffCanvasPaths',
'removeStyleElement',
'removeScriptElement',
'reusePaths',
],
};
2024-03-24 19:38:18 +02:00
export default config;