1

I know this is common question but every javascript and css packer/minifier i found is for node and contains a lot of necessary files/modules. Currenctly we are working on AngularJs application and we separated all our modules into different files and each controller also has it's own file (following this approach https://github.com/scotch/sapling). Also our server part is .NET MVC so we are not familiar with node or java tools.

This is what I need

  1. Package all .js files from folder including all child folders (unlimited deep)
  2. Decide if I want to run minification or just files concatenation
  3. Option to just run simple command to pack everything again

So basicly I need just simple packer and compress command line tool. I did some packing with Brunch but I on't like how it wraps my modules around with some code.

As an example here is code for Sapling

https://github.com/scotch/sapling

and here is how it looks packed (wrapped as modules)

http://sapling.scotchmedia.com/js/app.js

Anything simple that can fit these needs?

Andrej Kaurin
  • 11,592
  • 13
  • 46
  • 54
  • I'm confused. Are you looking for an AngularJS solution running on the server (is there such a beast?), or a .NET MVC asset caching and controller that can minify and compress on the fly as part of a request? It's more of a build situation, although you could lazily load content modularly with something like the [AMD (Asynchronous Module Definition) format](http://addyosmani.com/writing-modular-js/) is probably what you're best served with here for single-page apps. Also see [WHY AMD?](http://requirejs.org/docs/whyamd.html) at the Require.js documentation. – Jared Farrish Oct 20 '12 at 19:23
  • Well, I used AMD with require.js but I am not big fun of that. I will edit my question to be more clear. – Andrej Kaurin Oct 20 '12 at 21:09

1 Answers1

3

Ok, after some research I found that .NET MVC bundles can be used for that.

I found how to use non-minified version (for debug) even when debug=false. Credits goes to chrisortman:

Here is my code

public static void RegisterBundles(BundleCollection bundles)
    {
        BundleTable.EnableOptimizations = true;

        bundles.Add(new Bundle("~/bundles/vendor", new NonMinifyingJavascript())
            .IncludeDirectory("~/Areas/Qusion/App/libs/", "*.js", true));

        bundles.Add(new Bundle("~/bundles/app/finance", new NonMinifyingJavascript())
            .IncludeDirectory("~/Areas/Qusion/App/finance/", "*.js", true));
    }

NonMinifyingJavascript is from chrisortman link above.

Community
  • 1
  • 1
Andrej Kaurin
  • 11,592
  • 13
  • 46
  • 54
  • You don't need to use `NonMinifyingJavascript()`... In .NET MVC bundles, they shouldn't bundle or minify if you have `Debug="true"` in your Web.config file. I know this because it's what I use. ;) – Ben Lesh Oct 22 '12 at 18:17
  • Thanks, I know but in this way I have 2-3 non-minified files which I prefer over 100 files as – Andrej Kaurin Oct 23 '12 at 06:11