UNPKG

mytril

Version:

Mytril Svelte library component for rapidly building modern websites based on Svelte and Sveltekit

14 lines (13 loc) 398 B
/** * Minifies a given CSS string by removing comments, unnecessary whitespace, and newlines. * * @param css - The CSS string to be minified. * @returns The minified CSS string. */ export const cssMinimify = (css) => { css = css.replace(/\/\*[\s\S]*?\*\//g, ''); css = css.replace(/\s*([{};:,\s])\s*/g, '$1'); css = css.replace(/\n/g, ''); css = css.trim(); return css; };