# qx-fe-dev-server

> 前端开发服务器，需要支持代理功能

Latest version **0.1.2** (published 2018-05-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install qx-fe-dev-server
pnpm add qx-fe-dev-server
yarn add qx-fe-dev-server
bun add qx-fe-dev-server
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2018-05-14 |
| First published | 2018-05-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 30.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | lowequincy |

## Links

- npm: https://www.npmjs.com/package/qx-fe-dev-server
- Repository: https://github.com/QiaXue-Tech/fe-dev-server
- Homepage: https://github.com/QiaXue-Tech/fe-dev-server#readme
- Issues: https://github.com/QiaXue-Tech/fe-dev-server/issues
- npm.io page: https://npm.io/package/qx-fe-dev-server

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) ^10.0.8

## Recent versions

- 0.1.2 (latest) — 2018-05-14
- 0.1.1 — 2018-05-14
- 0.1.0 — 2018-05-14

## README

# fe-dev-server

前端开发服务器，支持代理功能

安装:

``` bash
npm install git+https://github.com/lowequincy/fe-dev-server.git
```

或者:

``` bash
npm install qx-fe-dev-server
```

- [x] 能够处理静态资源请求
- [x] 能够指定代理服务器的 `host`
- [x] 能够通过提供路径代理到指定的服务器，关键词可以是多个，比如数组： ['/api', '/services']
- [x] 能够通过 `yarn` 或者 `npm` 安装到任意前端项目，并且能通过调用函数启动 `httpServer`

## 设置代理功能

默认情况下不进行代理，如需要代理请求需要配置，代码如下：

``` node
const FeServer = require('qx-fe-dev-server');
const app = new FeServer();

app.router.proxyTable = {
    'api': {    // 'api' 是前端 ajax 请求中 url 的关键字，如 `/api/xxxxx/xxxx`,包含指定关键字则对请求进行转发
        host: 'localhost',
        port: 3000
    }
};

app.runServer();
```

## 设置起始页

默认情况下起始页为项目根目录下的 `index.html` 页面，如需指定其他起始页可进行如下配置：

``` node
const FeServer = require('qx-fe-dev-server');
const app = new FeServer();

app.indexPage = '/index1.html';     // 设置起始页

app.runServer();
```

## 打开指定html页面

``` node
const FeServer = require('qx-fe-dev-server');
const app = new FeServer();

app.renderView('/index', '/views/index.html');      // 将打开根目录下views目录中的 index.html 页面

app.runServer();
```

---
_Source: https://npm.io/package/qx-fe-dev-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
