UNPKG

3.9 kBMarkdownView Raw
1[![Build Status](https://travis-ci.org/Polymer/polyserve.svg?branch=master)](https://travis-ci.org/Polymer/polyserve)
2[![NPM version](http://img.shields.io/npm/v/polyserve.svg)](https://www.npmjs.com/package/polyserve)
3
4# polyserve
5
6A simple development server for web projects.
7
8`polyserve` serves project files from a URL root that allows relative URLs
9that reach out of the project, like those starting with `../`, to work. This is
10necessary for referencing other packages by path when stored as a flat directory
11such as how Bower works.
12
13The local package is served at the URL `/components/{bower-name}/`, with files
14served from the current directory. Other packages are served at
15`/components/{packageName}` with files served from their directory under
16`./bower_components/`.
17
18## Installation
19
20 $ npm install polyserve -g
21
22## Usage
23
24### Run `polyserve`
25
26 $ cd my-element/
27 $ polyserve
28
29### Browse files
30
31Navigate to `localhost:8080/components/my-element/demo.html`
32
33### Options
34
35 * `--version`: Print version info.
36 * `--root` _string_: The root directory of your project. Defaults to the current working directory.
37 * `--compile` _string_: Compiler options. Valid values are "auto", "always" and "never". "auto" compiles JavaScript to ES5 for browsers that don't fully support ES6.
38 * `--module-resolution` _string_: Algorithm to use for resolving module specifiers in import and export statements when rewriting them to be web-compatible. Valid values are "none" and "node". "none" disables module specifier rewriting. "node" uses Node.js resolution to find modules.
39 * `--compile-cache` _number_: Maximum size in bytes (actually, UTF-8 characters) of the cache used to store results for JavaScript compilation. Cache size includes the uncompiled and compiled file content lengths. Defaults to 52428800 (50MB).
40 * `-p`, `--port` _number_: The port to serve from. Serve will choose an open port for you by default.
41 * `-H`, `--hostname` _string_: The hostname to serve from. Defaults to localhost.
42 * `-c`, `--component-dir` _string_: The component directory to use. Defaults to reading from the Bower config (usually bower_components/).
43 * `-u`, `--component-url` _string_: The component url to use. Defaults to reading from the Bower config (usually bower_components/).
44 * `-n`, `--package-name` _string_: The package name to use for the root directory. Defaults to reading from bower.json.
45 * `--npm`: Sets npm mode: component directory is "node_modules" and the package name is read from package.json
46 * `-o`, `--open`: The page to open in the default browser on startup.
47 * `-b`, `--browser` _string[]_: The browser(s) to open with when using the --open option. Defaults to your default web browser.
48 * `--open-path` _string_: The URL path to open when using the --open option. Defaults to "index.html".
49 * `-P`, `--protocol` _string_: The server protocol to use {h2, https/1.1, http/1.1}. Defaults to "http/1.1".
50 * `--key` _string_: Path to TLS certificate private key file for https. Defaults to "key.pem".
51 * `--cert` _string_: Path to TLS certificate file for https. Defaults to "cert.pem".
52 * `--manifest` _string_: Path to HTTP/2 Push Manifest.
53 * `--proxy-path` _string_: Top-level path that should be redirected to the proxy-target. E.g. `api/v1` when you want to redirect all requests of `https://localhost/api/v1/`.
54 * `--proxy-target` _string_: Host URL to proxy to, for example `https://myredirect:8080/foo`.
55 * `--help`: Shows this help message
56
57## Compiling from Source
58
59 $ npm install
60 $ npm run build
61
62You can compile and run polyserve from source by cloning the repo from Github and then running `npm run build`. Make sure you have already run `npm install` before building.
63
64### Run Tests
65
66 $ npm test