mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-17 00:47:43 +01:00
* cleanup scripts * Move helpers to package * Fixes scripts * Fix scripts * Formatting * Fix helpers import paths * Remove lucide-figma * Rename helpers package * Fix build * formatting * Adjust main build-icons file * Add export casing * Adds `exportModuleNameCasing` fro lab project * format files * Bump package version @lucide/build-icons * Revert changes in icons * Revert changes in PR yml * Fix lint issues * Fix site build * fix lint errors * Attempt fix linting * Fix lint errors
40 lines
1023 B
JavaScript
40 lines
1023 B
JavaScript
/* eslint-disable import/no-extraneous-dependencies */
|
|
import { stringify } from 'svgson';
|
|
import { format } from 'prettier';
|
|
import { appendFile } from '@lucide/helpers';
|
|
|
|
export default function generateSprite(svgs, packageDir, license) {
|
|
const symbols = svgs.map(({ name, parsedSvg }) => ({
|
|
name: 'symbol',
|
|
type: 'element',
|
|
attributes: {
|
|
id: name,
|
|
},
|
|
children: parsedSvg.children,
|
|
}));
|
|
|
|
const spriteSvgObject = {
|
|
name: 'svg',
|
|
type: 'element',
|
|
attributes: {
|
|
xmlns: 'http://www.w3.org/2000/svg',
|
|
version: '1.1',
|
|
},
|
|
children: [
|
|
{
|
|
name: 'defs',
|
|
type: 'element',
|
|
children: symbols,
|
|
},
|
|
],
|
|
};
|
|
|
|
const spriteSvg = stringify(spriteSvgObject);
|
|
const prettifiedSprite = format(spriteSvg, { parser: 'babel' }).replace(/;/g, '');
|
|
|
|
const xmlMeta = `<?xml version="1.0" encoding="utf-8"?>\n<!-- ${license} -->\n`;
|
|
|
|
appendFile(xmlMeta, `sprite.svg`, packageDir);
|
|
appendFile(prettifiedSprite, `sprite.svg`, packageDir);
|
|
}
|