UNPKG

704 BJavaScriptView Raw
1// 此文件可或者 koa 中间件,所有 app 都会用到
2// 扩展时候需考虑普适性
3
4const path = require('path')
5
6module.exports = (server) => {
7
8 /* 静态目录,用于外界访问打包好的静态文件js、css等 */
9
10 const koaStatic = require('koa-static')
11 const convert = require('koa-convert')
12 // const rootPath = process.cwd() + '/dist/public'
13 const rootPath = path.resolve(process.env.SUPER_DIST_DIR, './public')
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}