Search code examples
javascriptasp.netangularjsvisual-studio-2012bundle

Visual Studio Bundle for SPA html index page


I'm trying to find a way to bundle scripts in Visual Studio. The catch is that I'm using an HTML file and not any ASPX files.

It is a SPA running Angular. The index.html has about 30 JS files I would like to bundle.

I tried using Web Essentials but it appears that that requires you to be running an ASPX page that compiles at run time?

Anyways - it would be nice to do this inside VS, however if I can't then a 3rd party external bundling tool would be fine. Just looking for suggestions on the easiest way to accomplish this.


Solution

  • You could take a look at using Cruncher. On GitHub or download via NuGet

    This will allow you to change your JavaScript references to bundle them together into one file.

    e.g.

    <script src="/js.axd?path=jquery-2.0.3.js|test.js|script.js|etc.js"></script>
    

    Or you can actually process the files to produce a static minified/bundled version of the files you want.