Add error notification for styles
This commit is contained in:
@@ -4,9 +4,11 @@ import fs from 'fs';
|
||||
import concat from 'concat';
|
||||
|
||||
export function concatVendors() {
|
||||
console.time('Concat in');
|
||||
|
||||
// Get all files in scripts/vendors/
|
||||
const files = fs.readdirSync(paths.scripts.vendors.src);
|
||||
|
||||
|
||||
// Extract no-JS files
|
||||
var jsFiles = files.filter((f)=>{
|
||||
if(f.includes('.js')) {
|
||||
@@ -15,16 +17,18 @@ export function concatVendors() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Add absolute path
|
||||
jsFiles = jsFiles.map((f) => {
|
||||
return `${paths.scripts.vendors.src + f}`;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// add files in node_modules example:
|
||||
// jsFiles.push('node_modules/gsap/dist/gsap.min.js');
|
||||
message('Concatenating vendors...', 'waiting');
|
||||
|
||||
concat(jsFiles, paths.scripts.dest + paths.scripts.vendors.main + '.js')
|
||||
}
|
||||
concat(jsFiles, paths.scripts.dest + paths.scripts.vendors.main + '.js').then(() => {
|
||||
message('Vendors concatenated', 'success', 'Concat in');
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@ export function buildScripts() {
|
||||
outfile: paths.scripts.dest + paths.scripts.main + '.js'
|
||||
}).catch((e) => {
|
||||
// errors managments (already done in esbuild)
|
||||
|
||||
notification({
|
||||
title: 'Javascript built failed 🚨',
|
||||
message: `${e.errors[0].text} in ${e.errors[0].location.file} line ${e.errors[0].location.line}`
|
||||
});
|
||||
|
||||
}).then(() => {
|
||||
message('Javascript built','success', 'JS built in')
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@ import sass from 'node-sass';
|
||||
import paths from '../mconfig.json';
|
||||
import fs from 'fs';
|
||||
import message from './utils/message.js';
|
||||
import notification from './notification.js';
|
||||
|
||||
export function compileStyles() {
|
||||
console.time('Styles built in');
|
||||
@@ -17,7 +18,12 @@ export function compileStyles() {
|
||||
|
||||
if(error) {
|
||||
message('Error compiling main.scss', 'error');
|
||||
console.log(error);
|
||||
console.log(error.formatted);
|
||||
|
||||
notification({
|
||||
title: 'main.scss compilation failed 🚨',
|
||||
message: `${error.formatted}`
|
||||
});
|
||||
} else {
|
||||
message('Styles built', 'success', 'Styles built in');
|
||||
}
|
||||
|
||||
@@ -4,17 +4,17 @@ import kleur from 'kleur';
|
||||
export default function message(text, type, timerId) {
|
||||
|
||||
if(type === 'success') {
|
||||
console.log(kleur.bgGreen().black(` ✅ ${text} `));
|
||||
console.log(kleur.bgGreen().black(`${text} ✅`));
|
||||
|
||||
if(timerId !== undefined) {
|
||||
console.timeEnd(timerId)
|
||||
}
|
||||
} else if (type === 'error') {
|
||||
console.log(kleur.bgRed(` 🚨 ${text} `));
|
||||
console.log(kleur.red().underline(`${text} ❌`));
|
||||
|
||||
} else if (type === 'waiting') {
|
||||
|
||||
console.log(kleur.blue().italic(` ⏱ ${text} `));
|
||||
console.log(kleur.blue().italic(`${text} ⏱ `));
|
||||
} else {
|
||||
console.log(text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user