WebMarkupMin icon indicating copy to clipboard operation
WebMarkupMin copied to clipboard

Support for Blazor WASM?

Open fingers10 opened this issue 1 year ago • 2 comments

Hi @Taritsyn

Thank you for this wonderful library. I searched the docs and issues and not able to find anything related to Blazor WASM. Does this support Blazor WASM? or can this be combined and used with https://github.com/jsakamoto/BlazorWasmPreRendering.Build which uses build time to prerender blazor wasm projects as HTML and can this be combined with it to Minify the HTML?

fingers10 avatar Jun 26 '24 18:06 fingers10

Hello, Abdul!

This issue will take some time to research. Most likely, I will have to add an additional property to the CommonHtmlMinificationSettingsBase class to prevent removing comments like these: <!-- %%-PRERENDERING-BEGIN-%% --> and <!-- %%-PRERENDERING-END-%% -->, so that author of the BlazorWasmPreRendering.Build can independently implement this functionality inside his repository.

Taritsyn avatar Jun 27 '24 06:06 Taritsyn

Hello, Abdul!

In version 2.17.0 a new property was added to HTML and XHTML minification settings - PreservableHtmlCommentList (default is empty). PreservableHtmlCommentList property takes a сomma-separated list of string representations of simple regular expressions, that define what HTML comments can not be removed (e.g. "/^\s*saved from url=\(\d+\)/i, /^\/?\$$/, /^[\[\]]$/").

Simple regular expressions somewhat similar to the ECMAScript regular expression literals. There are two varieties of the simple regular expressions:

  1. /pattern/
  2. /pattern/i

When implementing integration with the BlazorWasmPreRendering.Build library, you need to use the following settings:

var htmlMinifier = new HtmlMinifier(
    new HtmlMinificationSettings()
    {
        PreservableHtmlCommentList = @"/ %%-PRERENDERING(?:-HEADOUTLET)?-(?:BEGIN|END)-%% /"
    }
);

Taritsyn avatar Aug 07 '24 11:08 Taritsyn