egg默认安装了 egg-static
egg-static封装了 koa-static-cache https://github.com/koajs/static-cache

config.static

修改 egg-static的静态目录
config/config.default.js
https://eggjs.org/zh-cn/basics/structure.html#mobileAside

  1. config.static = {
  2. prefix: '/assert/',
  3. dir: path.join(appInfo.baseDir, 'app/assert'),
  4. }

view 视图引入静态资源

  1. <link rel="stylesheet" href="/public/css/bootstrap.css">
  2. <link rel="icon" href="/public/image/favicons/favicon.ico">

egg-static

egg-static的默认配置,查看:node_modules/egg-static
image.png

koajs/static-cache