pkgtrends faviconpkgtrends


A gulp-based asset pipeline for Express.

Taro Circle CI

An extensible asset-pipeline for Express, that uses gulp and plugins to process files.

WIP: This project is still in progress and is not ready for production use.


$ npm install taro --save


Taro offers a superagent-esque chainable system for describing how your files should be processed.

var express = require('express');
var app = express();

var Taro = require('taro');

function taro() {
	return new Taro({ root: './assets' })
			.use(autoprefix, { browsers: ['last 2 versions'] })
				.when('production' === process.env.NODE_ENV, csso)
				.when('production' === process.env.NODE_ENV, uglify)

app.use('/assets/', taro());

You can also package Taro in a local module, which has the advantage of cleanly separating your app's dependencies from the swath of gulp plugins used to compile your front-end.


Taro can be broken down into two components: a Server and set of Tasks.


Create a new task that runs when the request matches glob. By default, this task loads the requested file unless overridden by Server#source.

taro.get('**/*.css') // runs task on /file.css, /another.css, and /path/to/file.css
taro.get('*.css') // runs task on /file.css, and /another.css but *not* /path/to/file.css
taro.get('file.css') // runs task only on /file.css

Aliased as Server#for and Server#task.

Server#alias(ext, alias)

Aliases requests for ext to all associated aliases. For example, if scss is aliased to css, then requesting styles.css will look for styles.css and styles.scss.

By default we alias SASS, SCSS, LESS, and CoffeeScript extensions. Use this if you'd like to add your own custom aliases.

	.alias('css', 'newext')
	.get('styles.css') // will look for styles.css and styles.newext


Return Express-ready middleware.

// or, namespace some the URLs
app.use('/assets', taro.middleware());


Uses a set of source files for a given task. Use this if your source file to destination file is not a 1:1 relationship. This just calls gulp.src under the hood.

// concatenates all the js files in `js/libraries/` into a single file
	.use(concat, 'libraries.js')

Aliased as Task#src

Task#use(plugin[, opts...])

Use plugin with opts when processing files. Do not call the plugins with (), simply pass them into use.

	.use(sass) // Note how we don't call the function `()`. This is important.
	.use(prefix, opts) // You can pass plugin options through subsequent arguments

Task#when(condition, plugin[, opts...])

Use plugin with opts if condition evaluates to true. This is particularly useful for applying plugins to specific environments.

		.when('production' === process.env.NODE_ENV, uglify)

This will always use the 6to5 gulp plugin, but will only run uglify on production environments.


Taro passes errors onto your Express application. So if a request 404s, it will be handled by your application's code.

Asset compilation errors get passed on as a 500 error.


This package caches compiled files and serves from the cache to ensure fast response times. Files are only re-compiled when a newer source file is found.


To run the tests simply use:

npm install
npm test



pkgtrendsâ„— 2023