slet-plugin-static
v1.0.1
Published
Downloads
4
Readme
slet-plugin-static
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)
- 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