mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-17 14:28:25 +00:00
Fix broken icons illustrator, sketch and figma (#547)
* generate supersprite * add optimizer * optimize svgs * update snapshots
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import Svgo from 'svgo';
|
||||
import { optimize } from 'svgo';
|
||||
import { format } from 'prettier';
|
||||
import { parseSync, stringify } from 'svgson';
|
||||
import DEFAULT_ATTRS from './default-attrs.json';
|
||||
@@ -9,17 +9,25 @@ import DEFAULT_ATTRS from './default-attrs.json';
|
||||
* @param {string} svg - An SVG string.
|
||||
* @returns {Promise<string>} An optimized svg
|
||||
*/
|
||||
function optimize(svg) {
|
||||
const svgo = new Svgo({
|
||||
async function optimizeSvg(svg) {
|
||||
const result = optimize(svg, {
|
||||
plugins: [
|
||||
{ convertShapeToPath: false },
|
||||
{ mergePaths: false },
|
||||
{ removeAttrs: { attrs: '(fill|stroke.*)' } },
|
||||
{ removeTitle: true },
|
||||
{
|
||||
name: 'preset-default',
|
||||
params: {
|
||||
overrides: {
|
||||
convertShapeToPath: false,
|
||||
mergePaths: false,
|
||||
removeAttrs: {
|
||||
attrs: '(fill|stroke.*)',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
return svgo.optimize(svg).then(({ data }) => data);
|
||||
return result.data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +50,7 @@ function setAttrs(svg) {
|
||||
*/
|
||||
function processSvg(svg) {
|
||||
return (
|
||||
optimize(svg)
|
||||
optimizeSvg(svg)
|
||||
.then(setAttrs)
|
||||
.then(optimizedSvg => format(optimizedSvg, { parser: 'babel' }))
|
||||
// remove semicolon inserted by prettier
|
||||
|
||||
Reference in New Issue
Block a user