chore: optimize assets
@@ -4,7 +4,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "pnpm download-contributors && vite build",
|
"build": "node ./scripts/build.js",
|
||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
"clean": "rm -rf node_modules && rm -rf .svelte_kit && pnpm i",
|
"clean": "rm -rf node_modules && rm -rf .svelte_kit && pnpm i",
|
||||||
@@ -18,7 +18,8 @@
|
|||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "npm run test:integration && npm run test:unit",
|
"test": "npm run test:integration && npm run test:unit",
|
||||||
"test:integration": "playwright test",
|
"test:integration": "playwright test",
|
||||||
"test:unit": "vitest"
|
"test:unit": "vitest",
|
||||||
|
"optimize": "node ./scripts/optimize-assets.js"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@9.4.0+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a",
|
"packageManager": "pnpm@9.4.0+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { fileURLToPath } from 'url';
|
|
||||||
import { build } from 'vite';
|
import { build } from 'vite';
|
||||||
import { downloadContributors } from './download-contributor-data.js';
|
import { downloadContributors } from './download-contributor-data.js';
|
||||||
|
|
||||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await downloadContributors();
|
await downloadContributors();
|
||||||
await build();
|
await build();
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { readdirSync, statSync } from 'fs';
|
import { readdirSync, statSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join, relative } from 'path';
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||||
|
const root_dir = join(__dirname, '../static');
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
jpeg: { quality: 80 },
|
jpeg: { quality: 80 },
|
||||||
@@ -33,10 +34,14 @@ function isImage(file) {
|
|||||||
return imageExtensions.includes(extension);
|
return imageExtensions.includes(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_relative_path(file) {
|
||||||
|
return relative(root_dir, file)
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
for (const file of walkSync(join(__dirname, '../static'))) {
|
for (const file of walkSync(join(__dirname, '../static'))) {
|
||||||
if (!isImage(file)) continue;
|
if (!isImage(file)) continue;
|
||||||
console.log(file);
|
console.log(get_relative_path(file));
|
||||||
|
|
||||||
const image = sharp(file);
|
const image = sharp(file);
|
||||||
const size_before = (await image.toBuffer()).length;
|
const size_before = (await image.toBuffer()).length;
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 3.5 MiB After Width: | Height: | Size: 2.7 MiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 978 KiB |
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 543 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 574 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 704 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 456 KiB After Width: | Height: | Size: 196 KiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 705 KiB After Width: | Height: | Size: 871 KiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 176 KiB After Width: | Height: | Size: 3.5 MiB |
|
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 738 KiB After Width: | Height: | Size: 918 KiB |
|
Before Width: | Height: | Size: 950 KiB After Width: | Height: | Size: 697 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 311 KiB After Width: | Height: | Size: 562 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 5.1 MiB After Width: | Height: | Size: 3.9 MiB |
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 856 KiB After Width: | Height: | Size: 860 KiB |
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 924 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 926 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 924 KiB |
|
Before Width: | Height: | Size: 265 KiB After Width: | Height: | Size: 356 KiB |
|
Before Width: | Height: | Size: 715 KiB After Width: | Height: | Size: 787 KiB |
|
Before Width: | Height: | Size: 263 KiB After Width: | Height: | Size: 250 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 262 KiB |
|
Before Width: | Height: | Size: 275 KiB After Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 259 KiB After Width: | Height: | Size: 241 KiB |