mirror of
https://github.com/locomotivemtl/locomotive-boilerplate.git
synced 2026-01-15 00:55:08 +08:00
Fix messages in styles.js
Fixed: - Expected file extension from `outfile` for variable `name`. - Expected structure of `err` in main catch (`err.formatted` is only available when thrown by node-sass). - Context of error messages when writing final CSS and source map to disk.
This commit is contained in:
@@ -18,7 +18,7 @@ export async function compileStyles() {
|
||||
infile,
|
||||
outfile
|
||||
}) => {
|
||||
const name = basename((outfile || 'undefined'), '.scss');
|
||||
const name = basename((outfile || 'undefined'), '.css');
|
||||
|
||||
const timeLabel = `${name}.css compiled in`;
|
||||
console.time(timeLabel);
|
||||
@@ -65,33 +65,33 @@ export async function compileStyles() {
|
||||
message(`${name}.css is empty`, 'notice', timeLabel);
|
||||
}
|
||||
}).catch((err) => {
|
||||
message(`Error compiling ${name}.scss`, 'error');
|
||||
message(`Error compiling ${name}.css`, 'error');
|
||||
message(err);
|
||||
|
||||
notification({
|
||||
title: `${name}.scss compilation failed 🚨`,
|
||||
title: `${name}.css save failed 🚨`,
|
||||
message: `Could not save stylesheet to ${name}.css`
|
||||
});
|
||||
});
|
||||
|
||||
if (result.map) {
|
||||
writeFile(outfile + '.map', result.map.toString()).catch((err) => {
|
||||
message(`Error compiling ${name}.scss`, 'error');
|
||||
message(`Error compiling ${name}.css.map`, 'error');
|
||||
message(err);
|
||||
|
||||
notification({
|
||||
title: `${name}.scss compilation failed 🚨`,
|
||||
title: `${name}.css.map save failed 🚨`,
|
||||
message: `Could not save sourcemap to ${name}.css.map`
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
message(`Error compiling ${name}.scss`, 'error');
|
||||
message(err.formatted);
|
||||
message(err.formatted || err);
|
||||
|
||||
notification({
|
||||
title: `${name}.scss compilation failed 🚨`,
|
||||
message: err.formatted
|
||||
message: (err.formatted || `${err.name}: ${err.message}`)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user