koot
Version:
Koot.js - React isomorphic framework created by CMUX
25 lines (20 loc) • 741 B
JavaScript
// 此文件可或者 koa 中间件,所有 app 都会用到
// 扩展时候需考虑普适性
const path = require('path')
const getDistPath = require('../utils/get-dist-path')
module.exports = (server) => {
/* 静态目录,用于外界访问打包好的静态文件js、css等 */
const koaStatic = require('koa-static')
const convert = require('koa-convert')
// const rootPath = getCwd() + '/dist/public'
const rootPath = path.resolve(getDistPath(), './public')
const option = {
maxage: 0,
hidden: true,
index: 'index.html',
defer: false,
gzip: true,
extensions: false
}
server.app.use(convert(koaStatic(rootPath, option)))
}