Clientside package handling with stitch for express apps.
Last updated 8 years ago by henrikjoreteg .
Repository · Original npm · Tarball · package.json
$ cnpm install express-stitch 
SYNC missed versions from official npm registry.


Simple tool for serving client-side apps built with stitch and express.js.


make it easy to:

  • serve stitch packages dynamically while developing
  • write/serve minified versions of packages to disk for production use


npm install express-stitch


A simple express server, example:

var express = require('express'),
    stitch = require('stitch'),
    stitcher = require('express-stitch');

// a simple stitch client-package
var clientApp = stitch.createPackage({
    paths: [__dirname + '/clientapp', __dirname + '/clientlib'],
    dependencies: [
        __dirname + '/public/jquery.js'

// set up express
var app = express();

app.configure(function () {
    // use gzip
    // serve our 'normal' static files as usual
    app.use(express['static'](__dirname + '/public')); // our normal static files

// if production, also serve the files built by stitch
app.configure('production', function () {
    app.use(express['static'](__dirname + '/public/build'));

// our special stitch package. We pass in the package and options specifying
// where to write the minified file. Notice we write them to a directory called "build"
// by specifying items in this order, the static middleware will always intercept this
// route in production (since a file now exists at that path). So this particular handler
// never gets called.
app.get('/app.js', stitcher(stitchPackages.main, {writePath: __dirname + '/public/build/app.js'}));

// at this point our html can just point to /app.js and will either get the minified/static
// version in production and the dynamically served stitch package in dev.



    // whether to run through minifier before writing to disk. default is `true`
    minify: true, 
    // if you want to pass additional compression options to uglify's minify function, here's where you do it.
    uglifyConfig: {},
    // if you set this it will write the compiled file here. If left blank it won't write it to disk.
    writePath: '/path/something.js', 
    // serve: let's you optionally disable serving the dynamic package. `true` is the default.
    serve: true 


Written by @henrikjoreteg. If you're an awesome person you should say hi to me on twitter.



Current Tags

  • 0.0.2                                ...           latest (8 years ago)

2 Versions

  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
Dependents (1)

Copyright 2014 - 2017 © |