1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00
Files
locomotive-boilerplate/build/tasks/svgs.js
Chauncey McAskill 589ec99135 Move tasks to a dedicated directory
Moved concat.js, scripts.js, styles.js, svgs.js to 'build/tasks/' directory.
2021-09-18 01:16:44 -04:00

43 lines
1.1 KiB
JavaScript

import paths from '../mconfig.json';
import message from '../utils/message.js';
import notification from '../utils/notification.js';
import mixer from 'svg-mixer';
/**
* Generates and transforms SVG spritesheets.
*/
export async function compileSVGs() {
[
{
includes: [ paths.svgs.src + '*.svg' ],
filename: 'sprite.svg'
},
].forEach(({
includes,
filename
}) => {
const outfile = paths.scripts.dest + filename;
const timeLabel = `${filename} compiled in`;
console.time(timeLabel);
mixer(includes, {
spriteConfig: {
usages: false
}
}).then((result) => {
result.write(outfile).then(() => {
message(`${filename} compiled`, 'success', timeLabel);
});
}).catch((err) => {
message(`Error compiling ${filename}`, 'error');
message(err);
notification({
title: `${filename} compilation failed 🚨`,
message: `${err.name}: ${err.message}`
});
});
});
};