Created: 2011-07-16 05:55
Updated: 2019-01-18 15:36
License: mit

Sardines is no longer maintained. Use Webpack, or browserify instead.

What is it?

Combine all node.js scripts into one file. Run it as a single executable, or online.


  • Combine all scripts into one (shrinkwrap method)
  • Asynchronously load all scripts (browserify method)
  • express middleware

JS Example

var sardines = require("sardines"),
fs = require("fs");

	entry: __filename
}, function(err, content) {
	fs.writeFile(__dirname + "/shrinkwrapped.js", content);

Express example

var server = require("express").createServer();
	directory: __dirname + "/public"

In your browser, load a script and append one of the following query arguments: shrinkwrap, browserify, or wrap.

Like so:

http://localhost:8080/js/app.js?browserify # asynchronously loads ALL scripts vs loading into one
http://localhost:8080/js/app.js?shrinkwrap # loads all scripts into one
http://localhost:8080/js/app.js?wrap # wraps the script in a function so it doesn't pollute the global namespace

Terminal Usage

Usage: sardines [include] -e [entry] -o [output] -p [port] -d -s

  -s, --server     run the http server             
  -d, --directory  public directory for http server  [default: cwd]
  -p, --port                                         [default: 8080]
  -m  --method                                       [default: "shrinkwrap"]

Terminal Examples

sardines -e app.js -o app.shrinkwrap.js -m shrinkwrap # shrinkwrap the app
sardines -s # start the server
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more