1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00

Add support for custom task labels

If ever the basename from the outfile or outdir is an insufficient description.

Example:

```json
"concats": [
    {
        "label": "third-parties",
        "includes": [
            "{% paths.scripts.src %}/vendors/*.js"
        ],
        "outfile": "{% paths.scripts.dest %}/vendors.js"
    }
]
```
This commit is contained in:
Chauncey McAskill
2021-12-03 13:22:59 -05:00
parent 47007cddaf
commit 1e7e90c8aa
4 changed files with 42 additions and 32 deletions

View File

@@ -49,11 +49,14 @@ export default async function compileSVGs(mixerOptions = null) {
loconfig.tasks.svgs.forEach(async ({
includes,
outfile
outfile,
label = null
}) => {
const filename = basename(outfile || 'undefined');
if (!label) {
label = basename(outfile || 'undefined');
}
const timeLabel = `${filename} compiled in`;
const timeLabel = `${label} compiled in`;
console.time(timeLabel);
try {
@@ -64,13 +67,13 @@ export default async function compileSVGs(mixerOptions = null) {
await result.write(outfile);
message(`${filename} compiled`, 'success', timeLabel);
message(`${label} compiled`, 'success', timeLabel);
} catch (err) {
message(`Error compiling ${filename}`, 'error');
message(`Error compiling ${label}`, 'error');
message(err);
notification({
title: `${filename} compilation failed 🚨`,
title: `${label} compilation failed 🚨`,
message: `${err.name}: ${err.message}`
});
}