2020-07-18 00:52:09 +02:00
|
|
|
import fs from 'fs';
|
|
|
|
|
import path from 'path';
|
2020-07-18 13:13:57 +02:00
|
|
|
import processSvg from './render/processSvg';
|
2020-07-18 00:52:09 +02:00
|
|
|
|
2020-07-18 12:53:05 +02:00
|
|
|
const ICONS_DIR = path.resolve(__dirname, '../icons');
|
2020-07-18 00:52:09 +02:00
|
|
|
|
2020-07-18 12:53:05 +02:00
|
|
|
console.log(`Optimizing SVGs in ${ICONS_DIR}...`);
|
2020-07-18 00:52:09 +02:00
|
|
|
|
2020-07-18 12:53:05 +02:00
|
|
|
const svgFiles = fs.readdirSync(ICONS_DIR).filter(file => path.extname(file) === '.svg');
|
2020-07-18 00:52:09 +02:00
|
|
|
console.log(svgFiles);
|
|
|
|
|
|
2020-07-18 12:53:05 +02:00
|
|
|
svgFiles
|
|
|
|
|
.filter(file => path.extname(file) === '.svg')
|
|
|
|
|
.forEach(svgFile => {
|
|
|
|
|
const svg = fs.readFileSync(path.join(ICONS_DIR, svgFile));
|
2020-07-18 12:54:53 +02:00
|
|
|
processSvg(svg).then(svg => fs.writeFileSync(path.join(ICONS_DIR, svgFile), svg));
|
2020-07-18 12:53:05 +02:00
|
|
|
});
|