Search code examples
c#asp.net-coreminifyuglifyjs

prevent Uglify.JS from adding some changes


I am using Uglify.Js for my code and I am facing some hard times, the main part that drives me crazy is my code contains return x + await a + await b; and when I use Uglify.Js(code, codeSettings) the code turned to return x + await (a + await b); this is my codesettings:

CodeSettings codeSettings = new CodeSettings();
CodeSettings codeSettings = new CodeSettings();
codeSettings.MinifyCode = false;
codeSettings.OutputMode = OutputMode.MultipleLines;
codeSettings.BlocksStartOnSameLine = BlockStart.SameLine;
codeSettings.IndentSize = 1;
code = Uglify.Js(code, codeSettings).ToString();

Solution

  • Finally after spending a while I came with some changes, since my purpose of using the Uglify.Js was just for removing comments and unnecessary whitespace, so I used another JavaScript minifier which is lighter and do just what I wanted.

    the Minifier that I have used is JSMin by Douglas Crockford:

    http://www.crockford.com/javascript/jsmin.html

    http://www.crockford.com/javascript/jsmin.cs