You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
✨ Minifies and obfuscates the class names in HTML #169
<html><head><styletitle="master">.text\:center{text-align: center }.font\:16\:hover:hover{font-size:1rem}</style></head><body><h1class="text:center font:16:hover"></h1></body></html>
@1aron Sir Is it okay if I request more information, or is there anything else you would like assistance with? I'm here to resolve this issue?
import{MasterCSS}from'../core';import{Config,renderHTML,minify}from'@master/css';// Import renderHTML and minifyimportgenerateFromHTMLfrom'./generate-from-html';/** * Renders the page-required and sorted CSS text from HTML and injected it back into HTML * @param html * @param config * @returns html text */exportdefaultfunctionrenderHTMLWithMinification(html: string,config?: Config): string{if(!html)return;letreplaced=false;html=html.replace(/(<styleid="master">).*?(<\/style>)/,(_,prefix,suffix)=>{replaced=true;returnprefix+generateFromHTML(html,config)+suffix;});if(replaced){returnminify(html);// Minify the HTML if styles were replaced}conststyleText=`<style id="master">${generateFromHTML(html,config)}</style>`;constminifiedHtml=minify(html.replace(/<\/head>/,`${styleText}$&`));returnminifiedHtml;}[](URL)
Activity
itsezc commentedon Feb 23, 2023
Would it not be possible to merge class
aandbto reduce the overall output CSS and classes used? i.e the CSS could look like:now
ccould be used by multiple elements, and it would just be the 1 class1aron commentedon Feb 24, 2023
Great start! It may be possible, but more complete test cases are needed to confirm whether it will conflict with the current API.
pragyamishra56 commentedon Oct 6, 2023
@ If it would be possible then can you assign me to this issue I want to resolve this would be my first contribution
1aron commentedon Oct 6, 2023
Welcome! It's recommended to refer https://github.com/master-co/css/blob/beta/packages/css/src/functions/render-html.ts
pragyamishra56 commentedon Oct 6, 2023
@1aron Thank you so much, Sir for assigning me this issue
pragyamishra56 commentedon Oct 6, 2023
@1aron Sir Is it okay if I request more information, or is there anything else you would like assistance with? I'm here to resolve this issue?
pragyamishra56 commentedon Oct 6, 2023
@1aron Sir Is this your main website?

1aron commentedon Oct 6, 2023
@pragyamishra56 I think you misunderstood.
minifyis the function to be implemented in the issue.pragyamishra56 commentedon Oct 7, 2023
@1aron Sir, could you please assist me? You mentioned that you want improvement in the section I referred to, correct?"
import { renderHTML } from '@master/css'
<style title="master"> .text\:center { text-align: center } .font\:16\:hover:hover { font-size: 1rem } </style>...
const html = renderHTML(html);
res.set('Content-Type', 'text/html');
res.send(Buffer.from(html));
Now with minifying:
import { renderHTML, minify } from '@master/css'
<style title="master"> .a { text-align: center } .b:hover { font-size: 1rem } </style>...
const html = minify(renderHTML(html));
res.set('Content-Type', 'text/html');
res.send(Buffer.from(html));
1aron commentedon Oct 11, 2023
Again, there is currently no
minifyfunction.