Created: 2011-07-07 03:40
Updated: 2015-07-17 01:35
License: mit

NOTICE: This project is no longer maintained. If you would like commit access to the repository please open up an issue. If you are still using this in production I would like to hear from you as well. It was fun putting this together but we eventually moved to different framework.


This is a port of Sam Stephenson's Stich and Alex MacCaw's Stitch-rb to ASP.NET. Stitch allows you to:

Develop and test your JavaScript applications as CommonJS modules in Node.js. Then Stitch them together to run in the browser.

In other words, this is a CommonJS JavaScript package management solution. It's terribly simple, bundling up all your applications JavaScript files without intelligently resolving dependencies. However, unless your application is very modular, it turns out thats all you need.


Install the nuget package into a web project.

Install-Package Stitch

This will modify your Web.config adding a HttpHandler for any files *.stitch.

Add a reference to a stitch file in your application page.

<script type="text/javascript" src="application.stitch"></script>

This reference will get caught by the HttpHandler and compile the stiched version of your application.


The nuget package will add three things to your Web.config.

  1. Define a new section called stitch
  2. Add the HttpHandler for all *.stitch files
  3. Add the stitch section
    <section name="stitch" type="Stitch.Web.StitchConfigurationSection, Stitch.Web"/>

    <compilation debug="true" targetFramework="4.0" />
      <add type="Stitch.Web.StitchHttpHandler, Stitch.Web" verb="*" path="*.stitch" />



      <compiler type="Stitch.Compilers.CoffeeScriptCompiler, Stitch.Core"/>
      <compiler type="Stitch.Compilers.JavaScriptCompiler, Stitch.Core"/>


You can configure several different options here.

The first section contains a entry for each directory you want compiled into the same application file. Each directory here will compile all sub directories.

The second section will be included in the application file but without encapsulating or compiling. They will simply be appended to the top.

The third section lists out the different compilers that are possible. Currently there is a CoffeeScriptCompiler and a JavaScriptCompiler.


In order for this to work in ASP.NET MVC you need to set it up to ignore the stitch files in your routing. Adding this line after the axd ignore should do it.

routes.IgnoreRoute("{stitch}", new { stitch = @"..stitch(/.*)?" });

Command Line

Another option to generate your application is through the Stitch.exe command line application. The options are as follows.

Stitch Command Line Compiler
Copyright (C) 2011 Nathan Palmer
Stitch [destination] options
  -r, --root=VALUE           Root path (default is working directory)
  -p, --paths=VALUE          Comma delimited list of paths that should be compiled
  -d, --dep=VALUE            Comma delimited list of dependencies that should be included
  -i, --identifier=VALUE     Identifier to use for including other files (default is require)
  -c, --compilers=VALUE      Comma delimited list of compilers to use (default is CoffeeScriptCompiler, JavaScriptCompiler)
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more