npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

taro

v0.0.7

Published

A gulp-based asset pipeline for Express.

Downloads

98

Readme

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.

Installation

$ npm install taro --save

Usage

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' })
		.get('**/*.css')
			.src('**/*.scss')
			.use(sass)
			.use(autoprefix, { browsers: ['last 2 versions'] })
				.when('production' === process.env.NODE_ENV, csso)
		.get('*.js')
			.use(6to5)
				.when('production' === process.env.NODE_ENV, uglify)
		.get('img/*.{png,jpg,gif}')
			.use(imagemin);
		.middleware();
}

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.

API

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

Server#get(glob)

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.

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

Server#middleware()

Return Express-ready middleware.

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

Task#source(glob)

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
taro
	.get('libraries.js')
	.source('js/libraries/**/*.js')
	.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.

taro
	.get('**/*.css')
	.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.

taro
	.get('**/*.js')
	.use(6to5)
		.when('production' === process.env.NODE_ENV, uglify)

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

Errors

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.

Performance

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.

Tests

To run the tests simply use:

npm install
npm test

License

MIT