Skip to content

masongzhi/koa-spa-static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-spa-static

用于koa部署单页面资源(仅推荐使用在 文档mock等 dev 服务)

use koa to deploy static single page application source (just recommend with dev server such as document or mock-server)

Requirements

koa 2.x

Installation

$ npm install koa-spa-static

Options

  • matchReg Regex of matching front-end pages
  • staticReg Regex of matching front-end static. Defaults to "/static"
  • root koa-static root root
  • opts koa-static opts options

Example

import koa from 'koa'
import spaStatic from 'koa-spa-static'
const app = koa()

app.use(spaStatic({
  matchReg: /^(?!\/api)/, // 不以/api开头的接口(not use "/api" as prefix)
  root: path.join(__dirname, './dist'),
}));

app.listen(3000)

console.log('listening on port 3000');

About

koa-static for single page

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published