use*_*842 9 asp.net asp.net-mvc-4 webgrease
WebGrease是一个在mvc4中找到的程序集,但它可以像Yahoo.Yui.Compressor一样使用吗?我想在C#控制台程序中使用webgrease.dll并将javascript字符串压缩到另一个.
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);
}
}
Run Code Online (Sandbox Code Playgroud)
小智 12
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