templates/vite-templates/scripts/postinstall.js
2026-04-12 21:03:18 +03:00

32 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { existsSync } from 'fs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
console.log('🔧 Проверка установки пакетов оптимизации изображений...');
const requiredBinaries = [
'node_modules/mozjpeg/vendor/cjpeg',
'node_modules/pngquant-bin/vendor/pngquant',
'node_modules/gifsicle/vendor/gifsicle'
];
let allInstalled = true;
requiredBinaries.forEach(binary => {
const fullPath = join(__dirname, '..', binary);
if (!existsSync(fullPath)) {
console.warn(`⚠️ Бинарный файл не найден: ${binary}`);
allInstalled = false;
}
});
if (allInstalled) {
console.log('✅ Все пакеты оптимизации изображений установлены корректно');
} else {
console.log(' Некоторые пакеты могут потребовать ручной установки');
console.log('💡 Попробуйте: pnpm rebuild или npm rebuild');
}