0

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.

Ryan Mann
  • 5,178
  • 32
  • 42
  • 1
    If you use `new Bundle(...` instead of new `ScriptBundle(...` that should concatenate your files without removing whitespace. See [here](http://stackoverflow.com/questions/11944745/asp-net-bundles-how-to-disable-minification) for a previous similar question – darth_phoenixx Dec 13 '15 at 11:22
  • That worked, but it turns out my IBundleTransform which does token replacements was also removing white spice, however I am not sure why. – Ryan Mann Dec 14 '15 at 07:12

0 Answers0