mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 09:26:14 -04:00
Removed lightningcss (#6509)
Co-authored-by: SamTv12345 <samtv12345@samtv12345.com>
This commit is contained in:
parent
c5b7442acd
commit
b84b4c0878
4 changed files with 28 additions and 149 deletions
|
@ -300,7 +300,13 @@ const getFileCompressed = async (filename, contentType) => {
|
|||
try {
|
||||
logger.info('Compress CSS file %s.', filename);
|
||||
|
||||
content = await compressCSS(filename, ROOT_DIR);
|
||||
const compressResult = await compressCSS(content);
|
||||
|
||||
if (compressResult.error) {
|
||||
console.error(`Error compressing CSS (${filename}) using terser`, compressResult.error);
|
||||
} else {
|
||||
content = compressResult.code.toString(); // Convert content obj code to string
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`CleanCSS.minify() returned an error on ${filename}: ${error}`);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
*/
|
||||
|
||||
const fsp = require('fs').promises;
|
||||
import path from 'node:path'
|
||||
import {expose} from 'threads'
|
||||
import lightminify from 'lightningcss'
|
||||
import {transform} from 'esbuild';
|
||||
|
||||
/*
|
||||
|
@ -22,23 +20,9 @@ const compressJS = async (content) => {
|
|||
* @param {string} filename - name of the file
|
||||
* @param {string} ROOT_DIR - the root dir of Etherpad
|
||||
*/
|
||||
const compressCSS = async (filename, ROOT_DIR) => {
|
||||
const absPath = path.resolve(ROOT_DIR, filename);
|
||||
try {
|
||||
const basePath = path.dirname(absPath);
|
||||
const file = await fsp.readFile(absPath, 'utf8');
|
||||
let { code } = lightminify.transform({
|
||||
errorRecovery: true,
|
||||
filename: basePath,
|
||||
minify: true,
|
||||
code: Buffer.from(file, 'utf8')
|
||||
});
|
||||
return code.toString();
|
||||
} catch (error) {
|
||||
// on error, just yield the un-minified original, but write a log message
|
||||
console.error(`Unexpected error minifying ${filename} (${absPath}): ${JSON.stringify(error)}`);
|
||||
return await fsp.readFile(absPath, 'utf8');
|
||||
}
|
||||
const compressCSS = async (content) => {
|
||||
return await transform(content, {loader: 'css', minify: true});
|
||||
|
||||
};
|
||||
|
||||
expose({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue