Something went wrong. Try again.
Festive overlays for your website 🎉 Drop in & celebrate the season with snow, sparkles, and more. www.npmjs.com/package/festive-js
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788#!/usr/bin/env node
import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync, statSync } from 'fs';import { resolve, dirname, join } from 'path';import { minify } from 'terser';
const pkg = JSON.parse(readFileSync('package.json', 'utf-8'));
// Ensure themes directory existsconst themesDir = 'dist/themes';if (!existsSync(themesDir)) { mkdirSync(themesDir, { recursive: true });}
// Function to recursively find all theme index.js filesfunction findThemeFiles(dir) { const themeFiles = []; if (!existsSync(dir)) { console.warn(`Themes directory not found: ${dir}`); return themeFiles; }
const items = readdirSync(dir); for (const item of items) { const itemPath = join(dir, item); const stat = statSync(itemPath); if (stat.isDirectory()) { const indexPath = join(itemPath, 'index.js'); if (existsSync(indexPath)) { themeFiles.push({ name: item, path: indexPath }); } } } return themeFiles;}
// Build themesasync function buildThemes() { const themeFiles = findThemeFiles('themes'); if (themeFiles.length === 0) { console.log('No theme files found in themes/ directory'); return; }
console.log(`Building ${themeFiles.length} theme(s)...`);
for (const theme of themeFiles) { try { console.log(`Building theme: ${theme.name}`); // Read theme file const themeCode = readFileSync(theme.path, 'utf-8'); // Minify the code const minified = await minify(themeCode, { compress: { drop_console: true, drop_debugger: true, pure_funcs: ['console.log', 'console.warn', 'console.error'], }, mangle: true, format: { comments: false, }, });
// Write minified theme const outputPath = join(themesDir, `${theme.name}.min.js`); writeFileSync(outputPath, minified.code); console.log(`✓ Built ${theme.name}.min.js`); } catch (error) { console.error(`✗ Failed to build ${theme.name}:`, error.message); } } console.log('Theme building complete!');}
buildThemes().catch(console.error);