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.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
import { defineConfig } from "vite";import { readFileSync } from "fs";
const pkg = JSON.parse(readFileSync("package.json", "utf-8"));
// Plugin to minify CSS in template literalsconst minifyCSSInJS = () => { return { name: 'minify-css-in-js', generateBundle(options, bundle) { if (process.env.BUILD_MODE === 'min') { Object.keys(bundle).forEach(fileName => { const chunk = bundle[fileName]; if (chunk.type === 'chunk' && chunk.code) { // Minify CSS within template literals chunk.code = chunk.code.replace(/`([^`]*(?:\s+[^`]*)*)`/g, (match, css) => { if (css.includes('{') && css.includes('}')) { // This looks like CSS, minify it const minified = css .replace(/\s*{\s*/g, '{') .replace(/\s*}\s*/g, '}') .replace(/\s*;\s*/g, ';') .replace(/\s*:\s*/g, ':') .replace(/\s*,\s*/g, ',') .replace(/\s+/g, ' ') .replace(/^\s+|\s+$/g, '') .replace(/\n/g, ''); return '`' + minified + '`'; } return match; }); } }); } } };};
const banner = `/*! * ${pkg.name} v${pkg.version} * Copyright (c) 2025 ${pkg.author} * Licensed under the ${pkg.license} License * Built: ${new Date().toISOString()} */`;
const isMinified = process.env.BUILD_MODE === 'min';
export default defineConfig({ plugins: [minifyCSSInJS()], build: { outDir: "dist", emptyOutDir: false, minify: isMinified ? "esbuild" : false, sourcemap: false, lib: { entry: "entry.core.js", name: "Festive", fileName: () => isMinified ? "core.min.js" : "core.js", formats: ["iife"] }, rollupOptions: { treeshake: true, output: { banner: isMinified ? "" : banner, extend: false, compact: isMinified, exports: 'default', generatedCode: { constBindings: true } } }, target: "es2018", cssCodeSplit: false }, esbuild: isMinified ? { drop: ["console", "debugger"], minifyWhitespace: true, minifyIdentifiers: true, minifySyntax: true, keepNames: false } : undefined});