Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including harp-static with all npm packages installed. Try it out:

var harpStatic = require("harp-static")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

harp-static v0.1.0

Simple static server for harp.js

Harp Static

Simple Harp.js static server.

With Harp.js, if you want your source content files to work as a static generated site, then you must refer to urls using .html.

I don't like this.

So this script quite simply creates a static server (that caches assets), and maps normal Harp urls (i.e. without an extension on .html) and maps them to real files.

Now you can use non-static for development, and static for live (deployed to Heroku, etc).

Example of usage (and in fact, how I'm using harp-static):

'use strict';
var harp = require('harp');
var server = require('harp-static');
var outputPath = __dirname + '/www';
var port = process.env.PORT || 9000;

harp.compile(__dirname, outputPath, function (errors){
  if (errors) {
    console.log(JSON.stringify(errors, null, 2));
    process.exit(1);
  }

  console.log('Running harp-static on ' + port);
  server(outputPath, port);
});

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free