32 lines
689 B
JavaScript
Raw Normal View History

/**
* External depedencies
*/
2020-12-19 17:34:52 -05:00
const path = require('path');
const sharp = require('sharp');
2021-11-30 23:38:46 -05:00
const fs = require('fs-extra');
2020-12-19 17:34:52 -05:00
/**
* Internal depedencies
*/
const svgPath = path.resolve(__dirname, '..', 'src', 'logo.svg');
const iconsPath = path.resolve(__dirname, '..', 'src', 'extensionIcons');
2020-12-19 17:34:52 -05:00
const targetSizes = [16, 32, 48, 128];
// Build extension icons.
2021-11-30 23:38:46 -05:00
fs.ensureDir(iconsPath).then(generateIcons);
2020-12-19 17:34:52 -05:00
/**
* Generate extension icons.
*
* @since 1.4.0
*/
function generateIcons() {
targetSizes.forEach((size) => {
sharp(svgPath)
.png()
.resize({ width: size, height: size })
.toFile(`${iconsPath}/icon-${size}.png`)
.catch(console.error);
});
2020-12-19 17:34:52 -05:00
}