mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-13 13:48:26 +00:00
Improve optimize script
This commit is contained in:
@@ -20,7 +20,7 @@ export default function(fileName, outputDirectory, componentGetter, iconNodes) {
|
||||
|
||||
// Generate export for all the icons
|
||||
//
|
||||
// output: export const myIcon = getComponent(myIconVNode);
|
||||
// (output): export const myIcon = getComponent(myIconVNode);
|
||||
icons.forEach(iconName => {
|
||||
const componentName = generateComponentName(iconName);
|
||||
const constantString = `export const ${componentName} = ${componentGetter}(${componentName}VNode);\n`;
|
||||
|
||||
+11
-9
@@ -1,16 +1,18 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const OUT_DIR = path.resolve(__dirname, '../dist/icons');
|
||||
const ICONS_DIR = path.resolve(__dirname, '../icons');
|
||||
|
||||
console.log(`Optimizing SVGs in ${OUT_DIR}...`);
|
||||
console.log(`Optimizing SVGs in ${ICONS_DIR}...`);
|
||||
|
||||
const svgFiles = fs.readdirSync(IN_DIR).filter(file => path.extname(file) === '.svg');
|
||||
const svgFiles = fs.readdirSync(ICONS_DIR).filter(file => path.extname(file) === '.svg');
|
||||
console.log(svgFiles);
|
||||
|
||||
|
||||
// Object.keys(icons).forEach(name => {
|
||||
// const svg = icons[name].toSvg();
|
||||
|
||||
// fs.writeFileSync(path.join(OUT_DIR, `${name}.svg`), svg);
|
||||
// });
|
||||
svgFiles
|
||||
.filter(file => path.extname(file) === '.svg')
|
||||
.forEach(svgFile => {
|
||||
const svg = fs.readFileSync(path.join(ICONS_DIR, svgFile));
|
||||
processSvg(svg).then(svg =>
|
||||
fs.writeFileSync(path.join(ICONS_DIR, svgFile), svg),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import Svgo from 'svgo';
|
||||
import cheerio from 'cheerio';
|
||||
import { format } from 'prettier';
|
||||
|
||||
import DEFAULT_ATTRS from '../src/default-attrs.json';
|
||||
import DEFAULT_ATTRS from './default-attrs.json';
|
||||
|
||||
/**
|
||||
* Process SVG string.
|
||||
|
||||
Reference in New Issue
Block a user