UNPKG

717 BJavaScriptView Raw
1// 此文件可或者 koa 中间件,所有 app 都会用到
2// 扩展时候需考虑普适性
3
4const getDistPath = require('../utils/get-dist-path')
5const getDirDistPublic = require('../libs/get-dir-dist-public')
6
7module.exports = (server) => {
8
9 /* 静态目录,用于外界访问打包好的静态文件js、css等 */
10
11 const koaStatic = require('koa-static')
12 const convert = require('koa-convert')
13 const rootPath = getDirDistPublic(getDistPath())
14 const option = {
15 maxage: 0,
16 hidden: true,
17 index: 'index.html',
18 defer: false,
19 gzip: true,
20 extensions: false
21 }
22 server.app.use(convert(koaStatic(rootPath, option)))
23}