MinifyWorker: Fix buggy error handling in `compressCSS`
parent
98f0e931fe
commit
24b22e3a6d
|
@ -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) => {
|
||||
try {
|
||||
const absPath = path.resolve(ROOT_DIR, filename);
|
||||
try {
|
||||
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');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue