Added esbuild for minification

This commit is contained in:
SamTV12345 2024-06-03 21:40:31 +02:00
parent ee777cdec1
commit 2fab20b8dd
2 changed files with 8 additions and 6 deletions

View file

@ -3,13 +3,15 @@
* Worker thread to minify JS & CSS files out of the main NodeJS thread
*/
import Terser from 'terser'
const fsp = require('fs').promises;
import path from 'node:path'
import Threads from 'threads'
import {expose} from 'threads'
import lightminify from 'lightningcss'
import {transform} from 'esbuild';
const compressJS = (content: string) => Terser.minify(content);
const compressJS = async (content: string) => {
return await transform(content, {minify: true});
}
const compressCSS = async (filename: string, ROOT_DIR: string) => {
const absPath = path.resolve(ROOT_DIR, filename);
@ -30,7 +32,7 @@ const compressCSS = async (filename: string, ROOT_DIR: string) => {
}
};
Threads.expose({
compressJS,
expose({
compressJS: compressJS,
compressCSS,
});

View file

@ -69,7 +69,6 @@
"socket.io": "^4.7.5",
"socket.io-client": "^4.7.5",
"superagent": "^9.0.2",
"terser": "^5.30.3",
"threads": "^1.7.0",
"tinycon": "0.6.8",
"tsx": "^4.11.2",
@ -97,6 +96,7 @@
"@types/sinon": "^17.0.3",
"@types/supertest": "^6.0.2",
"@types/underscore": "^1.11.15",
"esbuild": "^0.21.4",
"eslint": "^9.2.0",
"eslint-config-etherpad": "^4.0.4",
"etherpad-cli-client": "^3.0.2",