Preserve formatting and comments in Script Bundle

254 Views Asked by At

I have an api I built which is split into many files and have configured script bundles to build them into one. I want to provide two urls for the api to other teams in my company.

One Api will be fully minimized and is working as intended.

The other Api I want to be unminified and preserve all it's white space and commenting.

The code looks something like this:

        ScriptBundle clientApiScript = new ScriptBundle("~/ClientAPI/xyzApi.min.js");
        clientApiScript.Include(new string[]
        {
            "~/clientApi/xyzApi.js",
            "~/clientApi/services/*.js",
            "~/clientApi/directives/*.js",
            "~/clientApi/xyzApiEnd.js"
        });
        clientApiScript.Transforms.Add(new JSTokenReplaceTransform());

        ScriptBundle clientApiScriptNonMinified = new ScriptBundle("~/ClientApi/xyzapi.full.js");
        clientApiScriptNonMinified.Include(new string[]
        {
            "~/clientApi/xyzApi.js",
            "~/clientApi/services/*.js",
            "~/clientApi/directives/*.js",
            "~/clientApi/xyzApiEnd.js"
        });
        clientApiScriptNonMinified.Transforms.Clear();
        clientApiScriptNonMinified.Transforms.Add(new JSTokenReplaceTransform());

        BundleTable.Bundles.Add(clientApiScript);
        BundleTable.Bundles.Add(clientApiScriptNonMinified);

The second bundle for "xyzApi.full.js" is indeed not minified, but all white space, new lines, and comments are gone.

Is there any way I can get it to bundle and merely concatenate the files together in alphabetical order. I have named the files so that they are in the right order in alphabetical order.

0

There are 0 best solutions below