default minification using ajaxmin (no changing variable, function names - remove only comments and white space)

StackOverflow https://stackoverflow.com/questions/11844333

Pregunta

I am using microsoft ajax minifier and I am using below piece of code to minify CSS and JS files, I wish to remove only comments and white space. I do not wish to rename or change the variable name or function name.

how can I use the options for default minification which will remove only Space and comments from my css and JS files. My code for .net utility looks like below....

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace CallAjaxMin
{
class CallAjaxMin
{
    static void Main(string[] args)
    {
        try
        {

            string sWebsiteScriptsFolder = @"D:\NewMerchandising\Javascript";
            string[] strFiles = Directory.GetFiles(sWebsiteScriptsFolder);

            foreach (string file in strFiles)
            {
                string sSourceFileName = file;
                if (!((sSourceFileName == sWebsiteScriptsFolder + "\\eluminate.js") | (sSourceFileName == sWebsiteScriptsFolder + "\\EventMediaPlayer.js")))
                {
                    string sDestFile = file;
                    ProcessStartInfo processinfo = new ProcessStartInfo(@"C:\Program Files\Microsoft\Microsoft Ajax Minifier\AjaxMin.exe");

                    processinfo.Arguments = "\"" + sSourceFileName + "\" -o \"" + sDestFile + "\" -clobber";
                    Process.Start(processinfo);
                }

            }

        }
        catch (Exception ex)
        {
            System.Console.WriteLine(ex.ToString());
        }
    }
}

}

Any ideas on how to remove only comments and spaces from CSS and JS files both? Is there any specific parameters or something that I need to pass here?

¿Fue útil?

Solución

If you don't want to rename any variables or functions, simply add the -rename:none command-line argument to the Arguments string you are building. Check the documentation at http://ajaxmin.codeplex.com/wikipage?title=Command-Line%20Switches for a complete list of available switches.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top