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

connect-preprocessor

v0.1.2

Published

A preprocessor middleware for [Connect](http://www.senchalabs.org/connect/) that dynamically compiles files for development.

Downloads

10

Readme

connect-preprocessor

A preprocessor middleware for Connect that dynamically compiles files for development.

Usage

preprocessor(compiler, options, compilerOpts)

compiler

A string name of a built-in compiler or a module that has the necessary exports as defined below. Required.

options

A hash of options:

  • src - The directory base from which the preprocessor will find and compile source files. Defaults to ./.

  • opts - Specifies additional options to pass on to the compiler. Can be defined in the options hash or passed as the third argument to the preprocessor. Defaults to {}.

  • pattern - The regex pattern used to determine whether the compiler should handle the request. Defaults to /\<options.compExt>$/.

  • ext - The extension of the source files. Defaults to the ext export of the compiler.

  • compExt - The extension of the compiled files. Defaults to the compExt export of the compiler.

  • mime - The mime type to send in the content-type header of the response. Will automatically be set for any built-in compilers.

  • index - Specifies the default file to use as the directory index. Set to false to disable the feature entirely. Defaults to index.html.

compilerOpts

Any additional options to pass on to the compiler.

Example

var app = require('connect')();
var preprocessor = require('connect-preprocessor');

app.use(preprocessor('jade', { src: 'pages' }));
app.use('/templates', preprocessor('jade', { src: 'templates' }, { client: true }));
app.use('/scripts', preprocessor('coffee', { src: 'scripts' }));

app.listen(3000);

Compilers

Compiler exports

If the compiler you need does not exist, feel free to make a pull request. Alternatively, you can require a module in the first argument of the preprocessor:

var compiler = require('my-compiler');
app.use(preprocessor(compiler));

This module must export these methods:

  • compile (text, compilerOpts, callback) - A function that compiles the string of text. Any errors should be passed to the first argument of the callback; a successfully compiled string should be sent as the second argument to the callback: callback(err, compiled).

  • ext (compilerOpts) - A string (or function that returns a string) specifying the extension of the source files.

  • compExt (compilerOpts) - A string (or function that returns a string) specifying the extension of the compiled files.

An example can be seen here.