forked from github.com/GenderDysphoria.fyi
Moved new build process out of gulp folder
This commit is contained in:
45
build/favicon.js
Normal file
45
build/favicon.js
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
const fs = require('fs-extra');
|
||||
const actions = require('./actions');
|
||||
const { resolve } = require('./resolve');
|
||||
|
||||
function any (input) {
|
||||
for (const i of input) if (i) return i;
|
||||
return false;
|
||||
}
|
||||
|
||||
const MATCHES = [
|
||||
'favicon.png',
|
||||
'favicon.gif',
|
||||
'favicon.jpeg',
|
||||
'favicon.jpg',
|
||||
];
|
||||
|
||||
module.exports = exports = async function favicon () {
|
||||
|
||||
const input = any(await Promise.all(
|
||||
MATCHES.map((f) =>
|
||||
fs.exists(resolve(f)).then((y) => y && f),
|
||||
),
|
||||
));
|
||||
|
||||
if (!input) return [];
|
||||
|
||||
// input = resolve(input);
|
||||
const tasks = [ 32, 57, 64, 76, 96, 114, 120, 128, 144, 152, 180, 192, 196, 228 ].map((width) => ({
|
||||
input,
|
||||
output: `favicon${width}.png`,
|
||||
format: 'png',
|
||||
width,
|
||||
action: actions.image,
|
||||
}));
|
||||
|
||||
tasks.push({
|
||||
input,
|
||||
output: 'favicon.ico',
|
||||
format: 'ico',
|
||||
action: actions.image,
|
||||
});
|
||||
|
||||
return tasks;
|
||||
};
|
||||
Reference in New Issue
Block a user