mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 06:03:34 +01:00
Feat/lightningcss (#6427)
* Added lightning css for minification of css * Added esbuild for minification * Upgraded to Node 22 * Fixed. * Temporary change branch * Rebased changes.
This commit is contained in:
parent
b376688f75
commit
426174d491
8 changed files with 5329 additions and 3946 deletions
6
.github/workflows/backend-tests.yml
vendored
6
.github/workflows/backend-tests.yml
vendored
|
@ -24,7 +24,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node: [18, 20, 21]
|
||||
node: [18, 20, 22]
|
||||
steps:
|
||||
-
|
||||
name: Checkout repository
|
||||
|
@ -81,7 +81,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node: [18, 20, 21]
|
||||
node: [18, 20, 22]
|
||||
steps:
|
||||
-
|
||||
name: Checkout repository
|
||||
|
@ -211,7 +211,7 @@ jobs:
|
|||
-
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 21
|
||||
node-version: 22
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
|
|
2
.github/workflows/frontend-admin-tests.yml
vendored
2
.github/workflows/frontend-admin-tests.yml
vendored
|
@ -18,7 +18,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node: [20, 21]
|
||||
node: [20, 22]
|
||||
|
||||
steps:
|
||||
-
|
||||
|
|
6
.github/workflows/frontend-tests.yml
vendored
6
.github/workflows/frontend-tests.yml
vendored
|
@ -26,7 +26,7 @@ jobs:
|
|||
-
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 21
|
||||
node-version: 22
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
|
@ -92,7 +92,7 @@ jobs:
|
|||
uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 21
|
||||
node-version: 22
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
|
@ -159,7 +159,7 @@ jobs:
|
|||
-
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 21
|
||||
node-version: 22
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
|
|
|
@ -24,13 +24,13 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node: [18, 20, 21]
|
||||
node: [18, 20, 22]
|
||||
steps:
|
||||
-
|
||||
name: Check out latest release
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
ref: develop #FIXME change to master when doing release
|
||||
-
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
|
|
2
.github/workflows/windows.yml
vendored
2
.github/workflows/windows.yml
vendored
|
@ -34,7 +34,7 @@ jobs:
|
|||
-
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 21
|
||||
node-version: 22
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
|
|
9207
pnpm-lock.yaml
9207
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -3,31 +3,45 @@
|
|||
* Worker thread to minify JS & CSS files out of the main NodeJS thread
|
||||
*/
|
||||
|
||||
const CleanCSS = require('clean-css');
|
||||
const Terser = require('terser');
|
||||
const fsp = require('fs').promises;
|
||||
const path = require('path');
|
||||
const Threads = require('threads');
|
||||
import path from 'node:path'
|
||||
import {expose} from 'threads'
|
||||
import lightminify from 'lightningcss'
|
||||
import {transform} from 'esbuild';
|
||||
|
||||
const compressJS = (content) => Terser.minify(content);
|
||||
/*
|
||||
* Minify JS content
|
||||
* @param {string} content - JS content to minify
|
||||
*/
|
||||
const compressJS = async (content) => {
|
||||
return await transform(content, {minify: true});
|
||||
}
|
||||
|
||||
/*
|
||||
* Minify CSS 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 output = await new CleanCSS({
|
||||
rebase: true,
|
||||
rebaseTo: basePath,
|
||||
}).minify([absPath]);
|
||||
return output.styles;
|
||||
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}): ${error}`);
|
||||
console.error(`Unexpected error minifying ${filename} (${absPath}): ${JSON.stringify(error)}`);
|
||||
return await fsp.readFile(absPath, 'utf8');
|
||||
}
|
||||
};
|
||||
|
||||
Threads.expose({
|
||||
compressJS,
|
||||
expose({
|
||||
compressJS: compressJS,
|
||||
compressCSS,
|
||||
});
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
"dependencies": {
|
||||
"async": "^3.2.5",
|
||||
"axios": "^1.7.2",
|
||||
"clean-css": "^5.3.3",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"ejs": "^3.1.10",
|
||||
|
@ -51,9 +50,11 @@
|
|||
"jsonminify": "0.4.2",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"languages4translatewiki": "0.1.3",
|
||||
"lightningcss": "^1.25.1",
|
||||
"live-plugin-manager": "^1.0.0",
|
||||
"lodash.clonedeep": "4.5.0",
|
||||
"log4js": "^6.9.1",
|
||||
"lru-cache": "^10.2.0",
|
||||
"measured-core": "^2.0.0",
|
||||
"mime-types": "^2.1.35",
|
||||
"oidc-provider": "^8.4.5",
|
||||
|
@ -68,15 +69,13 @@
|
|||
"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",
|
||||
"ueberdb2": "^4.2.63",
|
||||
"underscore": "1.13.6",
|
||||
"unorm": "1.6.0",
|
||||
"wtfnode": "^0.9.2",
|
||||
"lru-cache": "^10.2.0"
|
||||
"wtfnode": "^0.9.2"
|
||||
},
|
||||
"bin": {
|
||||
"etherpad-healthcheck": "../bin/etherpad-healthcheck",
|
||||
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue