1.0.1 • Published 9 years ago

slet-plugin-static v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
9 years ago

slet-plugin-static

NPM version Build codecov.io js-standard-style

Install

$ npm i -S slet-plugin-static

Usages

'use strict'

const StaticPlugin = require('.')

const Slet = require('slet')

// 经典用法
Slet.plugin(StaticPlugin)

const app = new Slet({
  root: __dirname,
  debug: false
})

// lazy load plugin
app.static()

// app.start(3005)
module.exports = app

步骤

  • 1)const StaticPlugin = require('.')
  • 2)Slet.plugin(StaticPlugin)
  • 3) app.static()

参数

const app = new Slet({
  root: __dirname,
  debug: false,
  static: {
    path: this.opts.root + '/public',
    opts: {} // https://github.com/koajs/static#options
  }
})
  • path即static server的目录,默认是当前目录下的public目录

更多参见:https://github.com/koajs/static#options