MinifyWorker: Fix buggy error handling in `compressCSS`

pull/5284/head
Richard Hansen 2021-11-15 03:14:04 -05:00
parent 98f0e931fe
commit 24b22e3a6d
1 changed files with 3 additions and 2 deletions

View File

@ -5,14 +5,15 @@
const CleanCSS = require('clean-css');
const Terser = require('terser');
const fsp = require('fs').promises;
const path = require('path');
const Threads = require('threads');
const compressJS = (content) => Terser.minify(content);
const compressCSS = async (filename, ROOT_DIR) => {
const absPath = path.resolve(ROOT_DIR, filename);
try {
const absPath = path.resolve(ROOT_DIR, filename);
const basePath = path.dirname(absPath);
const output = await new CleanCSS({
rebase: true,
@ -22,7 +23,7 @@ const compressCSS = async (filename, ROOT_DIR) => {
} catch (error) {
// on error, just yield the un-minified original, but write a log message
console.error(`Unexpected error minifying ${filename} (${absPath}): ${error}`);
callback(null, content);
return await fsp.readFile(absPath, 'utf8');
}
};