Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use webgrease?

WebGrease is an assembly found in mvc4, but can it be used like Yahoo.Yui.Compressor? I want to use webgrease.dll in a C# console programe and compress a javascript string to another.

    class Program
    {
        static void Main(string[] args)
        {
            Yahoo.Yui.Compressor.JavaScriptCompressor c = new Yahoo.Yui.Compressor.JavaScriptCompressor();
            string s = "function    hello (name)  {  return 'hello '+ name + '!'; }";
            s = c.Compress(s);
            Console.WriteLine(s);
        }
    }
like image 945
user1729842 Avatar asked Feb 21 '14 04:02

user1729842


1 Answers

It is possible and quite easy. You can find WG.EXE in your Visual Studio folder. WG.EXE is actually the command line minifier that calls the same minification libraries. You can use it from command line, or from MSBuild or from any script of your choice to do the minification.

Here is a good article written by WG team on how to use WG from command line: https://kenhaines.net/webgrease-as-seen-in-visual-studio-2012/

you may also check https://webgrease.codeplex.com/documentation

for detail information

like image 144
eugchi Avatar answered Oct 13 '22 00:10

eugchi