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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vinyl-serve

v3.0.1

Published

Serves the vinyl stream directly

Downloads

426

Readme

vinyl-serve v3.0.1

Serves the vinyl stream directly

Build Status Build status codecov.io Greenkeeper badge

Usage

import gulp from "gulp";
import vinylServe from "vinyl-serve";
import someTransform from "./somewhere";

gulp.src("src/**/*.js")
  .pipe(someTransform())
  .pipe(vinylServe(7000));

This starts the server at port 7000 and, for example, localhost:7000/foo.js responses the transformed contents of src/foo.js.

Recipes

Serve multiple source streams

gulp.task("serve", function () {
  gulp.src("js/**/*.js")
    .pipe(someTransform())
    .pipe(vinylServe(7000));

  gulp.src("css/**/*.scss")
    .pipe(anotherTransform())
    .pipe(vinylServe(7000));

  gulp.src("html/**/*.html")
    .pipe(vinylServe(7000));
});

Modify the base path

gulp.src("./js/**/*.js", { base: "./" })
  .pipe(someTransform())
  .pipe(vinylServe(7000));

With the above example, if you have js/foo.js, it's served at the path /js/foo.js, not /foo.js.

Debug

At the address __vinyl__, you can see the debug page and find all the available paths in the server.

screenshot

API

var vinylServe = require("vinyl-serve");

vinylServe(port)

| param | type | description | | ----- | ------ | --------------------------------------------- | | port | number | The port number of the server (default: 7000) |

This returns stream processor which serves the contents at the given port.

vinylServe.stop(port)

| param | type | description | | ----- | ------ | --------------------------------------------- | | port | number | The port number of the server (default: 7000) |

This restarts the server at the given port number. Throws error if there is no server at the port.

vinylServe.restart(port)

| param | type | description | | ----- | ------ | --------------------------------------------- | | port | number | The port number of the server (default: 7000) |

This stops the server at the given port number. Throws error if there is no server at the port.

vinylServe.isServerReady(port)

| param | type | description | | ----- | ------ | --------------------------------------------- | | port | number | The port number of the server (default: 7000) |

This returns a promise which resolves when the server of the given port is ready. Returns null when server does't exist.

API for module developer

vinyl-serve has some more APIs which are maybe useful when someone wants to use this module as a part of another module.

vinylServe.setDebugPageTitle(title)

  • @param {String} title

This overrides the debug page title.

vinylServe.setDebugPagePath(path)

  • @param {String} path

This overrides the debug page path. The path have to start with '/'. (The default is __vinyl__.)

Example. /__mytool__

vinylServe.setHandlerOfStarting(handler)

  • @param {Function} handler

Sets the handler for the starting of the server. This handler is called when the server start listening. This handler is called with 2 parameters. The first one is the url of the root of the server and the second is the path of the debug page. ( e.g. http://0.0.0.0:7000/ and http://0.0.0.0:7000/__vinyl__ )

vinylServe.setHandlerOfPortError(handler)

  • @param {Function} handler

Sets the handler for the case of the port number error. This handler is called when the server's port is already in use. This handler is called with 1 parameter which is the port number of the server.

vinylServe.addMiddleware(middleware)

  • @param {Function} middlware The connect middleware

This adds the connect middleware to the server.

Install

npm install vinyl-serve

License

MIT

History

  • 2018-06-09 v3.0.1 Add addMiddleware API.
  • 2017-04-23 v2.7.0 Serve index.html.
  • 2016-12-29 v2.6.1 Windows bug fix.
  • 2016-12-29 v2.6.0 Update page design.
  • 2016-12-29 v2.5.3 Windows bug fix.
  • 2016-09-18 v2.4.0 Better mtime handling.
  • 2016-04-17 v1.3.3 Fix bug of binary data handling.