UNPKG

5.4 kBMarkdownView Raw
1# Harp
2
3> zero-configuration web server with built in pre-processing
4
5### What is Harp?
6
7Harp is a static web server that also serves Jade, Markdown, EJS, Less, Stylus, Sass, and CoffeeScript **as** HTML, CSS, and JavaScript without any configuration. It supports the beloved layout/partial paradigm and it has flexible metadata and global objects for traversing the file system and injecting custom data into templates. Optionally, Harp can also compile your project down to static assets for hosting behind any valid HTTP server.
8
9### Why?
10
11Pre-compilers are becoming extremely powerful and shipping front-ends as static assets has many upsides. It's simple, it's easy to maintain, it's low risk, easy to scale, and requires low cognitive overhead. I wanted a lightweight web server that was powerful enough for me to abandon web frameworks for dead simple front-end publishing.
12
13### Features
14
15- easy installation, easy to use
16- fast and lightweight
17- robust (clean urls, intelligent path redirects)
18- built in pre-processing
19- first-class layout and partial support
20- built in LRU caching in production mode
21- can export assets to HTML/CSS/JS
22- does not require a build steps or grunt task
23- fun to use
24
25### Supported Pre-Processors
26
27| | Language Superset | Whitespace Sensitive
28| --------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------
29| **HTML** | [EJS](http://embeddedjs.com/) | [Jade](http://jade-lang.com/), [Markdown](http://daringfireball.net/projects/markdown/)
30| **CSS** | [LESS](http://lesscss.org/), [Sass (SCSS)](http://sass-lang.com/) | [Stylus](http://learnboost.github.io/stylus/), [Sass](http://sass-lang.com/)
31| **JavaScript** | (TBD) | [CoffeeScript](http://coffeescript.org/)
32
33### Resources
34
35- **Server Documentation** - [harpjs.com/docs/](http://harpjs.com/docs/)
36- **Platform Documentation** - [harp.io/docs](https://harp.io/docs)
37- **Source Code** - [github.com/sintaxi/harp](https://github.com/sintaxi/harp)
38
39
40Authored and maintained by [@sintaxi](http://twitter.com/sintaxi). Made for the [@HarpPlatform](http://twitter.com/HarpPlatform).
41
42---
43
44### Installation
45
46 sudo npm install -g harp
47
48### Quick Start
49
50Creating a new harp application is a breeze...
51
52 harp init myproj
53 harp server myproj
54
55Your Harp application is now running at [http://localhost:9000]()
56
57---
58
59## Documentation
60
61Harp can be used as a library or as a command line utility.
62
63### CLI Usage
64
65 Usage: harp [command] [options]
66
67 Commands:
68
69 init [path] initalize new harp application (defaults to current directory)
70 server [path] [options] start harp server
71 compile [path] [options] compile project to static assets
72 multihost [path] [options] start harp server to host directory of harp apps
73
74 Options:
75
76 -h, --help output usage information
77 -V, --version output the version number
78
79Start the server in root of your application by running...
80
81 harp server
82
83You may optionally supply a port to listen on...
84
85 harp server --port 8002
86
87Compile an application from the root of your application by running...
88
89 harp compile
90
91You may optionally pass in a path to where you want the compiled assets to go...
92
93 harp compile --output /path/to/cordova/project/www
94
95### Lib Usage
96
97You may also use harp as a node library for compiling or running as a server.
98
99Serve up a harp application...
100
101```js
102var harp = require("harp")
103harp.server(projectPath [,args] [,callback])
104```
105
106**Or** compile harp application
107
108```js
109var harp = require("harp")
110harp.compile(projectPath [,outputPath] [, callback])
111```
112
113**Or** use as Connect/ExpressJS middleware
114
115```js
116var express = require("express");
117var harp = require("harp");
118var app = express();
119```
120
121```js
122// Express 3
123app.configure(function(){
124 app.use(express.static(__dirname + "/public"));
125 app.use(harp.mount(__dirname + "/public"));
126});
127```
128
129```js
130// Express 4
131
132app.use(express.static(__dirname + "/public"));
133app.use(harp.mount(__dirname + "/public"));
134
135```
136
137
138## License
139
140Copyright © 2012–2014 [Chloi Inc](http://chloi.io). All rights reserved.
141
142Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
143
144The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
145
146THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.