import { readdirSync, readFileSync, writeFileSync } from 'fs' import path from 'path' const ICONS_DIR = path.join('node_modules', '@tabler', 'icons', 'icons', 'outline') const CONTENTS = { HEAD: ``, TAIL: '' } const object = {} try { const fileNames = readdirSync(ICONS_DIR) fileNames.forEach((filename) => { const filePath = path.join(ICONS_DIR, filename) const contents = readFileSync(filePath, 'utf8').trim() const guts = contents .replace(/^]*>/, '') .replace(/<\/svg>$/, '') .replace(/\s{2,}/g, ' ') object[filename.slice(0, -4)] = guts }) const output = `// Generated by build.js at ${new Date().toISOString()} export default ${JSON.stringify({ ...object, HEAD: CONTENTS.HEAD, TAIL: CONTENTS.TAIL }, null, 2)}; ` writeFileSync('./icons.js', output) console.log('Icons successfully generated and saved to icons.js!') } catch (err) { console.error('Error processing icons:', err) }