mirror of
https://github.com/plausible/analytics.git
synced 2024-11-25 07:06:11 +03:00
add size reporter GH action (#4745)
This commit is contained in:
parent
8bd32b68c9
commit
b49fc82c2b
1
.github/workflows/node.yml
vendored
1
.github/workflows/node.yml
vendored
@ -32,3 +32,4 @@ jobs:
|
|||||||
- run: npm run check-format --prefix ./assets
|
- run: npm run check-format --prefix ./assets
|
||||||
- run: npm run test --prefix ./assets
|
- run: npm run test --prefix ./assets
|
||||||
- run: npm run deploy --prefix ./tracker
|
- run: npm run deploy --prefix ./tracker
|
||||||
|
- run: npm run report-sizes --prefix ./tracker
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"deploy": "node compile.js",
|
"deploy": "node compile.js",
|
||||||
"test": "npm run deploy && npx playwright test --config=./test/support/playwright.config.js",
|
"test": "npm run deploy && npx playwright test --config=./test/support/playwright.config.js",
|
||||||
|
"report-sizes": "node report-sizes.js",
|
||||||
"start": "node test/support/server.js"
|
"start": "node test/support/server.js"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
28
tracker/report-sizes.js
Normal file
28
tracker/report-sizes.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
|
const PrivTrackerDir = '../priv/tracker/js/';
|
||||||
|
|
||||||
|
const toReport = [
|
||||||
|
'plausible.js',
|
||||||
|
'plausible.pageleave.js',
|
||||||
|
'plausible.manual.pageleave.js',
|
||||||
|
'plausible.hash.pageleave.js'
|
||||||
|
];
|
||||||
|
|
||||||
|
const results = [];
|
||||||
|
|
||||||
|
toReport.forEach((filename) => {
|
||||||
|
const filePath = path.join(PrivTrackerDir, filename);
|
||||||
|
if (fs.statSync(filePath).isFile()) {
|
||||||
|
results.push({
|
||||||
|
'Filename': filename,
|
||||||
|
'Real Size (Bytes)': fs.statSync(filePath).size,
|
||||||
|
'Gzipped Size (Bytes)': execSync(`gzip -c -9 "${filePath}"`).length,
|
||||||
|
'Brotli Size (Bytes)': execSync(`brotli -c -q 11 "${filePath}"`).length
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.table(results)
|
Loading…
Reference in New Issue
Block a user