is there a way to remove comments from generated files?

51 views
Skip to first unread message

Bruno Henrique

unread,
Jun 14, 2019, 9:51:25 AM6/14/19
to SquishIt
Hello guys i'm using Squishit and it came to my mind if  there's a way to remove comments from generated files by AsNamed method?

I'm using a class to manage and create my bundles and these bundles are always reregistered when my application start then on my views i call those bundle key who create the tag for my generated file...
Example:

//File GLOBAL.ASASX
public class MvcApplication : HttpApplication{

public void RegisterBundles(){
   BundleSquishltHelper.IsToForceRelease(_default_isto_force_release);
   Bundle.Css().ClearCache();
   Bundle.JavaScript().ClearCache();
 
  //when only mycontroller it means my default action it's index, so the css represented below is for mycontroller.index.css or just mycontroller.css
   BundleSquishltHelper.NewCssBundle("cssmycontrollermyaction", new List<BundleSquishltHelper.Squishit>()
   {
                new BundleSquishltHelper.Squishit("~/assets/css/mycontroller.css"),
    });

}

}



public class BundleSquishltHelper{

//properties...

//methods...

public static void NewBundle(string key, BundleType type, List<Squishit> files){

//things go here
myinstance.AsNamed(key, renderToFile);


}

}

Alex Ullrich

unread,
Jun 24, 2019, 2:00:39 PM6/24/19
to SquishIt
This is typically a concern with the minifier itself.  Though it doesn't look like we are exposing a way to pass in the settings right now.

I can likely add this capability if you need it - it should be there IMO.  What version are you running currently?

Thanks,

Alex

Alex Ullrich

unread,
Aug 22, 2019, 7:50:19 AM8/22/19
to SquishIt
So I've reviewed this further and you can currently achieve this using the MsMinifier (this is the default currently).  Use the following in your global.asax.cs or owin startup:

            Configuration.Apply(iso =>
            {
                iso.DefaultCssMinifier = new MsMinifier(new CssSettings
                {
                    CommentMode = CssComment.None
                });
            });

I need to make the YuiMinifier constructors public but once that is done you will be able to do the same for YUI:

            Configuration.Apply(iso =>
            {
                iso.DefaultCssMinifier = new YuiMinifier(columnWidth: -1, compressionType: CompressionType.Standard, removeComments: true);
            });

Hopefully this helps.  I will try to get nuget updated today.

Alex

Bruno Henrique

unread,
Aug 28, 2019, 9:35:40 PM8/28/19
to SquishIt
Hey Alex thanks a lot for the working...

I was not able to answer but it's great to know that we'll be able to remove comments now...

A lot of thanks!

Alex Ullrich

unread,
Aug 29, 2019, 4:55:58 PM8/29/19
to SquishIt
No worries - I actually thought this was already there so thank YOU for pointing it out :)
Reply all
Reply to author
Forward
0 new messages